在鼠标悬停事件中更改图像 [英] changing image on mouseover event

查看:80
本文介绍了在鼠标悬停事件中更改图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

firends,

i hav写了以下代码,用于更改鼠标悬停事件中的图像源。

它在Chrome和mozilla中工作正常,但在IE中无效。

---------------------------------------------- -----------------------------------------

img src =images / - col --- fix-12.pngid =img2onmouseover =img2.src =''images / 1234.png''; onmouseout =img2.src =''images / - col --- fix-12.png'';

------------------------------------------ --------------------------------------------------

请整理出来。

提前预定

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

推荐答案

定义用于鼠标悬停和鼠标移除的JS方法。在这些方法中,重置源。



Ex:

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';
}


这篇关于在鼠标悬停事件中更改图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆