Naveen Yogi, Naveen Web Design, Web Designing

html,css,html5,css3,javascript,jquery blog there is queries with solution regarding the web designing

Pages

  • Home
  • HTML & CSS
  • jQuery

Monday, 9 April 2018

Add two random class on body in jQuery

<script>
    $(document).ready(function(){
var classes = ["yellow", "pink"];

$("body").each(function(){
    $(this).addClass(classes[~~(Math.random()*classes.length)]);
});
});
</script>
Posted by naveenwebdesign at 01:06
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

About Me

naveenwebdesign
View my complete profile

Blog Archive

  • ►  2023 (1)
    • ►  February (1)
  • ►  2022 (1)
    • ►  April (1)
  • ►  2019 (6)
    • ►  November (1)
    • ►  July (1)
    • ►  June (1)
    • ►  April (1)
    • ►  March (2)
  • ▼  2018 (7)
    • ▼  April (4)
      • How to create tabbing in jQuery
      • Add two random class on body in jQuery
      • Adding class randomly to HTML elements with jQuery
      • How to open dropdown menu on click
    • ►  March (2)
    • ►  January (1)
  • ►  2017 (16)
    • ►  September (1)
    • ►  August (1)
    • ►  July (2)
    • ►  June (2)
    • ►  May (1)
    • ►  April (5)
    • ►  March (1)
    • ►  February (3)
  • ►  2016 (13)
    • ►  July (9)
    • ►  June (2)
    • ►  May (2)
Simple theme. Powered by Blogger.