Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

toggle images on MouseOver

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
the problem:
i want an image on my website to toggle between two states everytime the user drags the mouse over it.
i've written the following script:
<script language=&quot;javascript&quot;>
<!--
var imgvec = new Array(&quot;img/img1.gif&quot;, &quot;img/img2.gif&quot;);

function toggle(source, imgsrc1, imgsrc2)
{
if(source.src == imgvec
)
{
source.src = imgvec
;
return;
}

source.src = imgvec
;
}
//-->
</script>

my image-tag is like this:
<img src=&quot;img/img2.gif&quot; onMouseOver=&quot;toggle(this, 0, 1)&quot;>

when i drag the mouse over the image the first time, it changes to img1.gif correctly. the second time i drag over the image it does not change back. :( the if() block is never executed...

has anyone an idea why?
 
Try this:

<img src=&quot;img/img2.gif&quot; onMouseOver=&quot;img/img1.gif&quot; onMouseOut=&quot;img/img2.gif&quot;>

Jonthequik
JS/HTML/XML
 
obviously you didn't get the point. i don't want a simple rollover-effect, the image should change only on MouseOver depending on what image is currently displayed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top