Click here to Skip to main content
12,753,195 members (39,782 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
i hav written following code for changing image source on mouseover event .
its working fine in chrome and mozilla bt not working in IE.
img src="images/--col---fix-12.png" id="img2" onmouseover="img2.src='images/1234.png';" onmouseout=" img2.src='images/--col---fix-12.png';"
please sort it out.
thanx in advance
Posted 14-Feb-13 4:40am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Define a JS method for mouseover and mouseout. In those methods, reset the source.

<img src="images/--col---fix-12.png" id="img2" onmouseover="SecondImage();" onmouseout="OriginalImage();"> 

function SecondImage()
  document.getElementById('img2').src = 'images/1234.png';
function OriginalImage()
  document.getElementById('img2').src = 'images/--col---fix-12.png';
Sergey Alexandrovich Kryukov 14-Feb-13 16:54pm
Correct, my 5, but it can be done more elegantly with jQuery.
Sandeep Mewara 15-Feb-13 0:09am
Thanks SA. I am with you. No doubt about it - almost all the JS operations can be done more elegantly using jQuery. :)

My answer was based on OP's question that looked like a beginner.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100