Reputation: 1
I need help changing this image when it is moused over. This does not work. Please help?
<a href="#" onmouseover="document.getElementById('gotosite').
src='b.png';"
onmouseout="document.getElementById('myimage1'src='bmo.png';">
<img src="b.png" id="gotosite" /></a>
Upvotes: 0
Views: 248
Reputation: 360
I see two problems with your code. First, in your onmouseout
code you have the wrong ID for the image. It should be gotosite
but you you have myimage1
. Also, you're missing some parentheses and a period following document.getElementById('myimage1'
.
Try this:
<a href="#" onmouseover="document.getElementById('gotosite').src='b.png';" onmouseout="document.getElementById('gotosite').src='bmo.png';"><img src="b.png" id="gotosite" /></a>
Here is a fiddle using this code with only the image URLs changed:
http://jsfiddle.net/jwnace/w2cL69x3/
Upvotes: 0
Reputation: 399
try this:
<img src="image.png" onmouseover="this.src='image.png'" onmouseout="this.src='image.png'" width="70" height="70" alt="">
Upvotes: 2