jQuery Mouseenter/Mouse离开图像交换 [英] Jquery Mouseenter/Mouse Leave image swap
本文介绍了jQuery Mouseenter/Mouse离开图像交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我写了这段代码来尝试一些新的方式来进行图像交换以进行预加载,这给我带来了麻烦.
So I wrote this little bit of code to try out some new way of doing an image swap for purposes of preloading and I am having a bit of trouble.
我的问题是我有一个带有图像的容器,其中包含一些填充和文本,但是只有当有人将鼠标悬停在图像上时,才会激活我的翻转.我一定有一点点错,希望有人可以帮助我.还在学习!
My problem is that I have a container with the images that has some padding and text, but the activation of my rollover only happens when someone rolls over the image, instead of the container. I must have some small bit wrong, hopefully someone can help me out. Still learning!
这是html:
<div class="projectThumb">
<img src="/img/aeffect_button_static.gif" width="146" height="199" class="static" name="aeffect" alt="" />
<img src="/img/aeffect_button_rollover.jpg" width="146" height="199" class="rollover" name="aeffect" alt="" />
<p class="title">A.EFFECT: Film Poster</p>
</div>
这是jquery:
$(document).ready(function(){
$(".rollover").hide();
$(".projectThumb").mouseenter(
function(){
$(this).attr(".static").hide();
},
function(){
$(this).attr(".rollover").show();
});
$(".projectThumb").mouseleave(
function(){
$(this).attr(".rollover").hide();
},
function(){
$(this).attr(".static").show();
});
});
推荐答案
查看全文