[英]Add class with delay JQuery then remove and loop this function
got this problem were i need this function to work as a loop (or atleast i think thats what I want). 遇到了这个问题,因为我需要将此功能作为一个循环工作(或者至少我认为那是我想要的)。
It works the first time I enter #nav and leave but the second time I want to enter the navigation the addClass function is not working. 它在我第一次输入#nav并离开时有效,但是第二次我想进入导航时,addClass函数不起作用。
$("#nav").mouseenter(function() {
$(".desktop a").delay(300).queue(function(){$(this).addClass('showhidden')});
});
$("#nav").mouseleave(function() {
$(".desktop a").removeClass("showhidden");
});
You need to dequeue it: 您需要将其出队:
$(".desktop a").dequeue().delay(300).queue(function(){$(this).addClass('showhidden')});
And: 和:
$(".desktop a").dequeue().removeClass("showhidden");
Or just use: 或者只是使用:
$(".desktop a").clearQueue().removeClass("showhidden");
Remove Class 删除课程
setTimeout(function() {
elements.removeClass(className);
}, 4000);
Add Class 新增课程
setTimeout(function() {
elements.attr('class','classname');
}, 4000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.