在链接悬停时显示div,当光标离开形式div和链接隐藏div jquery时
问题描述:
我有链接,并且当鼠标悬停在div上时,它会悬停在div上,并显示div.
I have link and on hover it should display the div when leave cursor form div and link it should hide div.
<a href="javascript:void(0);" id="show_div">2 items</a>
<div id="dropcart">contents</div>
<script type="text/javascript">
$(document).ready(function(){
$("#show_div").hover(function(){
$("#dropcart").fadeIn();
});
});
</script>
答
已根据您的评论进行了更新:
Updated as per your comments:
$("#show_div").hover(function(){
$("#dropcart").fadeIn();
});
$("#dropcart").mouseleave(function(){
if($("#show_div").is(':hover') === false)
$("#dropcart").fadeOut("fast");
});