jQuery-如何使用stopPropagation() [英] jQuery - how to use stopPropagation()
本文介绍了jQuery-如何使用stopPropagation()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以前已经做过,但是我很难让它开始工作...
I've done this before, but I'm having trouble getting this to work...
我需要以下jquery具有.stopPropagation函数,因此,如果用户将鼠标悬停在三个元素上的速度过快,动画将不会发疯!
I need the following jquery to have a .stopPropagation function, so the animation won't go crazy if the user hovers over three elements too quickly!
$(function () {
var tabContainers = $('div.subMenu > div');
tabContainers.hide();
$('.mainMenuDiv a').hover(
function (e) {
tabContainers.filter(this.hash).slideDown();
e.stop();
},
function(e){
tabContainers.filter(this.hash).slideUp();
e.stopPropagation();
});
});
推荐答案
听起来像您正在寻找stop
函数来取消所有不完整的动画.
Sounds like you are looking for the stop
function that cancels any incomplete animations.
$('.mainMenuDiv a').hover(
function (e) {
tabContainers.filter(this.hash).stop().slideDown();
},
function(e){
tabContainers.filter(this.hash).stop().slideUp();
}
);
或者如果您希望任何正在进行的动画回滚",请尝试:
or if you'd like any in-progress animation(s) to be "rolled back" try:
$('.mainMenuDiv a').hover(
function (e) {
tabContainers.filter(this.hash).stop(true, true).slideDown();
},
function(e){
tabContainers.filter(this.hash).stop(true, true).slideUp();
}
);
查看文档以获得更多信息.
这篇关于jQuery-如何使用stopPropagation()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文