Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Javascript
firends,
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 3:40am
maan_k446

1 solution

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

Solution 1

Define a JS method for mouseover and mouseout. In those methods, reset the source.
 
Ex:
<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';
}
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 14-Feb-13 16:54pm
   
Correct, my 5, but it can be done more elegantly with jQuery.
—SA
Sandeep Mewara at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.140821.2 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
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