在链接悬停时显示div,当光标离开形式div和链接隐藏div jquery时 [英] on link hover display div when leave cursor form div and link hide div jquery

查看:79
本文介绍了在链接悬停时显示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"); 
});

演示

这篇关于在链接悬停时显示div,当光标离开形式div和链接隐藏div jquery时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆