jquery中在两个拥有相同mouseover的元素之间移动的问题
$('#d11,#d12').on('mouseover',function(){
$('#d2').animate({opacity:'100'});
});如代码所示,在d11,d12之间移动,animate会执行照成物体一闪一闪的,怎么解决。详细代码如下:
Document
// 先终断之前的动画$(document).ready(function(){
$('#d11,#d12').on('mouseover',function(){
$('#d2').stop(true).animate({opacity:'100'});
});
$('#d11,#d12').on('mouseout',function(){
$('#d2').stop(true).animate({opacity:'0'});
});
});方法1:
不需要js,css加一句:
#d1:hover~#d2{opacity:1}不过得注意下d1宽度……
方法2:
加个新类.opa1{opacity:1}然后用addClass和removeClass做。
animate前先stop掉动画。或者用封装好的.hover()










