如何在鼠标移动时更改图像src? [英] how to change image src whene mouse move?
本文介绍了如何在鼠标移动时更改图像src?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< img src =rk.jpgalt =rajkumarclass =imgh>< / img>
这是我的形象,我想用鼠标移动此图像上的chane img src。
.imgh:悬停
{
}
i想要改变img src在悬停的帮助下。
plz help ....
解决方案
只需试试这个。
< img src = rk.jpg alt = rajkumar class = imgh onmouseover = this.src ='your image name'; onmouseout = this.src ='rk.jpg'; > < 跨度> / img >
希望它有所帮助:)
这实际上是需要 javascript的任务,它也不是一项复杂的任务,可以在没有深入的知识。
但是,如果你想要一个使用纯css的相似解决方案,尝试将img更改为div,使用css设置display:block
以及图片大小的宽度和高度。然后使用background-image
将图片放在那里,并在鼠标悬停时修改该属性。
解决方案
使用 jQuery [ ^ ],让生活更轻松。
代码
dear sir,
<img src="rk.jpg" alt="rajkumar" class="imgh"></img>
this is my image, i want to do chane img src whene mouse moves on this image.
.imgh:hover
{
}
i want to change img src with the help of hover.
plz help....
解决方案
Simply try this.
<img src="rk.jpg" alt="rajkumar" class="imgh" onmouseover="this.src='your image name';" onmouseout="this.src='rk.jpg';"></img>
Hope it helps :)
This really is a task that requires javascript, and it's not a complex task either and can be done without "in-depth" knowledge.
However, if you want a look-alike solution using pure css, try changing the img to a div, using css to setdisplay: block
and the width and height to the size of your picture. Then place the picture there withbackground-image
, and modify that property on mouseover.
Solution
Use jQuery[^], which makes life easier.
Code
这篇关于如何在鼠标移动时更改图像src?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文