View Single Post
Old 08-22-2011, 04:56 PM  
potter
Confirmed User
 
Industry Role:
Join Date: Dec 2004
Location: Denver
Posts: 6,559
Quote:
Originally Posted by candyflip View Post
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.
__________________

potter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote