I'd like to add a random class to the body element with jQuery
I'd like to be able to have a list of classes (ie. .bgimg1{},.bgimg2{}, .bgimg3{}
, etc) and randomly insert one into the body element of my pages.
I can do HTML and CSS, but I'm 开发者_如何学JAVAa programming luddite, so please type slowly. :)
you can do this:
var classes = ['bgimg1','bgimg2', 'bgimg3']; //add as many classes as u want
var randomnumber = Math.floor(Math.random()*classes.length);
$('body').addClass(classes[randomnumber]);
精彩评论