Quote:
Originally Posted by candyflip
The big gossip blogs that run on Wordpress all manage to do this.
|
I already posted how to do it.
Here's the jquery if he doesn't have it:
Code:
<script type="text/javascript">
var images = ['foo.jpg', 'bar.jpg', 'image.jpg'];
function setImage() {
return images[Math.floor(Math.random() * images.length)];
}
$('.background-switch').click(function() {
$(this).css('background-image':setImage());
});
</script>
^ I literally just wrote that out without testing, but in theory it should work just fine. Basically, each time you click on the background-switch div, it'll switch the background image css to a random one selected from the images variable.