问题
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