I have a simple onMouseOver and Out image changer.
<div id="img1" onMouseOver="changeBg('imgs/1col.png', 'img1')" onMouseOut="changeBg('imgs/1.png', 'img1')"></div>
<div id="img2" onMouseOver="changeBg('imgs/2col.png', 'img2')" onMouseOut="changeBg('imgs/2.png', 'img2')"></div>
function changeBg (image, id) {
var div = document.getElementById(id);
div.style.backgroundImage = "url("+image+")";
}
However I have like 50 images I would like to apply this effect on, is there an easier way to write this, as a JS function to count automatically and get it to return values etc? so like: "imgs/" + i + "col.png" "img" + i
Thanks for all you help
EDIT: anyone able to help on thiss?