jQuery鼠标移动到子元素边缘也触发mouseout事件
jQuery鼠标移动到子元素边缘也触发mouseout事件,这会导致鼠标在元素上移动时,下拉框不停的闪<divclass="commodity-box"><divclas...
jQuery鼠标移动到子元素边缘也触发mouseout事件,这会导致鼠标在元素上移动时,下拉框不停的闪
<div class="commodity-box">
<div class="box" style="z-index: 99;">
<div class="commodity-img">
<img src="zz.jpg" />
</div>
<div class="title">
<a href="#">标题标题</a>
</div>
<div class="pandb">
<em><b>¥</b>11</em>
<a href="#" class="buy">立即购买</a>
</div>
</div>
<div class="mmesg">ssss</div>
</div>
<script type="text/javascript">
$('.commodity-box').mouseover(function(){
$(this).css('z-index', '99');
var mmesg = $(this).find('.mmesg');
var height = $(this).height();
var mheight = mmesg.height();
var mm = height-mheight;
mmesg.css({'top': mm, 'display' : 'block'});
mmesg.stop().animate({'top' : height+"px"}, 100, 'linear');
});
$('.commodity-box').mouseout(function(){
var mmesg = $(this).find('.mmesg');
var height = $(this).height();
var mheight = mmesg.height();
var mm = height-mheight;
$(this).css('z-index', '0');
mmesg.stop().animate({'top' : mm+'px'}, 100, 'linear', function(){
$(this).css('display', 'none');
});
})
</script>
代码如上,求解释 展开
<div class="commodity-box">
<div class="box" style="z-index: 99;">
<div class="commodity-img">
<img src="zz.jpg" />
</div>
<div class="title">
<a href="#">标题标题</a>
</div>
<div class="pandb">
<em><b>¥</b>11</em>
<a href="#" class="buy">立即购买</a>
</div>
</div>
<div class="mmesg">ssss</div>
</div>
<script type="text/javascript">
$('.commodity-box').mouseover(function(){
$(this).css('z-index', '99');
var mmesg = $(this).find('.mmesg');
var height = $(this).height();
var mheight = mmesg.height();
var mm = height-mheight;
mmesg.css({'top': mm, 'display' : 'block'});
mmesg.stop().animate({'top' : height+"px"}, 100, 'linear');
});
$('.commodity-box').mouseout(function(){
var mmesg = $(this).find('.mmesg');
var height = $(this).height();
var mheight = mmesg.height();
var mm = height-mheight;
$(this).css('z-index', '0');
mmesg.stop().animate({'top' : mm+'px'}, 100, 'linear', function(){
$(this).css('display', 'none');
});
})
</script>
代码如上,求解释 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询