[英]problem with Drop-Down Menu in jQuery and css
why slideDown()
and slideUp()
does not work true on my menu? 为什么
slideDown()
和slideUp()
在我的菜单上不起作用?
They are repeated several times with mouseover()
. 使用
mouseover()
它们重复几次。
see you: jsfiddle-my codes 见: jsfiddle-my代码
$('#nav li').mouseover(function() {
$('#nav li ul li').slideDown();
})
.mouseout(function(){
$('#nav li ul li').slideUp();
})
Try using hover
(a shortcut for mouseenter
and mouseleave
) instead, and change your selector: 尝试改用
hover
( mouseenter
和mouseleave
的快捷方式),然后更改选择器:
$('#nav > li').hover(function() {
$('#nav li ul li').slideDown();
}, function() {
$('#nav li ul li').slideUp();
})
Example: http://jsfiddle.net/andrewwhitaker/jdsGx/ 示例: http : //jsfiddle.net/andrewwhitaker/jdsGx/
Previously, the events were bound to all li
s under #nav
. 以前,事件在
#nav
下绑定到所有li
。 I think you just want direct children, which the child selector will get you 我想您只想要直接的孩子, 孩子选择器会带给您
I would do this: 我会这样做:
http://jsfiddle.net/5KEnp/4/ http://jsfiddle.net/5KEnp/4/
$('#nav > li').mouseenter(function() {
$('ul li', this).stop(true, true).slideDown();
}).mouseleave(function(){
$('ul li', this).stop(true, true).slideUp();
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.