这是我的代码jsbin link。正如你所看到的,只要我从触发器上悬停,下拉菜单就会关闭,导致导航无效。如何保持悬停后下拉导航打开?
任何简单的解决方案将是非常受欢迎的。提前致谢。
HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<header>
<p>Menu</p>
<ul>
<li>list</li>
<li>list</li>
<li>list</li>
<li>list</li>
</ul>
</header>
</body>
</html>
SASS
*
margin: 0
header
padding: 20px
background-color: tomato
p
display: inline
padding: 5px 10px
background-color: blue
color: white
&:hover
cursor: pointer
ul
padding: 10px
background-color: blue
list-style: none
color: white
width: 60px
display: none
JS
$(function(){
$("p").hover(function(){
$("ul").slideToggle();
});
});
'mouseenter' /'在格mouseleave' – melancia
包装和使用悬停的DIV http://jsfiddle.net/mohamedyousef1980/wfw1f9to/1/ –