[英]JQuery reversing SlideToggle in Wordpress
I have the following simple code: 我有以下简单的代码:
jQuery( document ).ready(function( $ ) {
$('.menu ul li:has("ul")').hover(function() {
$('>ul', this).stop().slideToggle();
});
});
I'm using the 'no conflict' way of firing jQuery but for some reason my slide toggle is closing on hover rather than opening! 我使用的是触发jQuery的“无冲突”方式,但由于某种原因,我的幻灯片切换开关在悬停时关闭,而不是打开! What am I doing wrong?
我究竟做错了什么? I'm sure its simple but I just can't see it.
我敢肯定它很简单,但我看不到它。
An example can be seen here http://ng1club.everythingcreative.co.uk 可以在此处查看示例http://ng1club.everythingcreative.co.uk
Use mouseenter
and mouseleave
instead. 请改用
mouseenter
和mouseleave
。 Sometimes hover
without the second function as a hover out, triggers twice. 有时
hover
没有第二个功能悬停时,便会触发两次。
$('.menu ul li:has("ul")').mouseenter(function() {
$('>ul', this).stop().slideDown();
}).mouseleave(function() {
$('>ul', this).stop().slideUp();
});
Try this according to documentation you can use hover and apply effect on hover and hover out 根据文档尝试此操作,您可以使用悬停并将效果应用于悬停和悬停
jQuery('.menu ul li:has("ul")').hover(
function() {
jQuery('>ul', this).stop().slideDown();
}, function() {
jQuery('>ul', this).stop().slideUp();
}
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.