jquery: mouseout applies to nested elements

泄露秘密 提交于 2019-12-07 12:18:28

问题


ul with links nested in a div layer. mouse pointer goes over .title, ul is shown.

the problem: mouseout() applies to nested elements


mouseout() is for the div


<div>
  <a class="title">Section A</a>
     <ul>
        <li><a href=''>link 1</a></li>
        <li><a href=''>link 2</a></li>
        <li><a href=''>link 3</a></li>
     </ul> 
</div>



$('.title').mouseover(function() {
   $('ul').slideDown();
})

$('div').mouseout(function(){
   $('ul').slideUp();
});

回答1:


Try $('selector').mouseleave(function(){});



来源:https://stackoverflow.com/questions/3867128/jquery-mouseout-applies-to-nested-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!