View Full Version : Help with Javascript on rollOver

09-22-2011, 01:51 AM
I have a div in my HTML that that when rolled over reveals an image.

I can't figure out how to place a random image from a set of 5 images to appear in the background of that div when it is rolled over again. Please help me!

09-22-2011, 03:29 AM
There is more than one way of writing this. Hope it helps

<div id='picture' onmouseover="mouseover()"></div>

function mouseover(){
var rand_Img = Math.floor(Math.random()*5+1);
var img_roll_over = document.getElementById('picture').style.backgroundImage="url(Image_"+rand_Img+".jpg)";


09-22-2011, 03:41 AM
awesome thank you!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum