我有这个查询,它工作正常,除了当我单击已经打开的切换项目时,它会向上滑动,但随后会立即向下滑动。可以看到here 。
查询是:
$(".faqtopics").click(function(event) {
$("div.faqtext").slideUp(400);
$(this).next("div.faqtext").slideToggle();
});
非常感谢您的帮助!
最佳答案
使用.stop()
Description: Stop the currently-running animation on the matched elements.
代码
$(".faqtopics").click(function(event) {
$("div.faqtext").stop(true).slideUp(400);
$(this).next("div.faqtext").stop(true).slideToggle();
});
关于javascript - Jquery切换: closing a toggle element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24386031/