Click here to Skip to main content
11,487,979 members (80,226 online)
Rate this: bad
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 at 14-Feb-13 16:54pm
Correct, my 5, but it can be done more elegantly with jQuery.
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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 489
1 OriginalGriff 353
2 Advay Pandya 155
3 Mehdi Gholam 145
4 Sascha Lefèvre 135
0 Sergey Alexandrovich Kryukov 9,308
1 OriginalGriff 8,352
2 Sascha Lefèvre 3,334
3 Maciej Los 2,956
4 Richard Deeming 2,370

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