我是jquery的新手。我正在构建一个图像组合。 基本上我有2个div类。而在主要课堂上,我有一个形象。 当我用鼠标在主DIV上输入时,我得到第二个div来动画。 它的效果很好,但是当我复制主DIV 2或更多时间时,在MOUSEENTER上每个DIV都会被触发。我怎样才能让鼠标触发的DIV,其他人不受影响。谢谢。 我会给你我的jQuery和HTML代码。并提供我的问题是什么的形象。如何让jquery mouseenter只影响一个DIV
的jQuery:
$(document).ready(function() {
$(".main").mouseenter(function() {
$(".blue").animate({
left: '0px',
opacity: '0.6',
}, "slow");
})
$(".main").mouseleave(function() {
$(".blue").animate({
left: '-250px',
opacity: '1.0',
}, "slow");
});
});
HTML:
<div class="main" style="margin:0 auto;background:#cecece;height:100px;width:350px;position: relative;overflow: hidden;">
<div class="blue" style="background:#09bbfd;z-index:100;height:100px;width:250px;left:-250px;position:absolute;opacity:0.5;">
</div>
<a href="#">
<img src="uploads/windows.jpg" alt="windows">
</a>
</div>
考虑使用[CSS3过渡](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Transitions/Using_CSS_transitions),而不是实现此目的。 – fisk