AffetePhize
New Member
I'm trying to pass an id of an img to a function on mouseover so that i can use this javascript on multiple images on one page?i'm trying to change the img_id to whatever is being mouseoveredCan anyone please take a shot at this one?Thanks!\[code\]<img src="http://coolimg2.1.jpg" alt="http://coolimg2."onmouseover="animate();"onmouseout="stopAnimation();"id="myImg1" class="sample"/><img src="http://coolimg3.1.jpg" alt="http://coolimg3."onmouseover="animate();"onmouseout="stopAnimation();"id="myImg2" class="sample"/><p id="test" /><script type="text/javascript"src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('.sample').mouseover(function() { $('#test').html(this.id); }); }); var myImages = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]var img_index = 0;var timer;//I'm trying to change the img_id to what is being mouseovered on. not "myimg2"var img_id = "myImg2";var imgsrc = http://stackoverflow.com/questions/14536807/document.getElementById(img_id).alt;// Start animationfunction animate() { me = document.getElementById(img_id); me.src = imgsrc + myImages[img_index] +".jpg" img_index++; if (img_index == myImages.length){ img_index = 0; } timer = setTimeout(animate, 500);}function stopAnimation() { clearTimeout(timer);}</script>\[/code\]