本文介绍了jQuery slideToggle调用一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那可能很简单,但是大约是凌晨2点,而且很困:)

That just could be very simple, but it's about 2AM and getting quite sleepy :)

我有一个简短的脚本,该脚本可以使"slideToggle" div不显示.

I have short script which "slideToggle" div from being non-displayed.

$('#cmnt_add').click(function () { $('.dark_div_add').slideToggle(1100); });

是否有机会进行一次锻炼,所以如果打开未显示的DIV,单击相同的链接将无济于事?

Is there a chance to make it workout once, so if non-displayed DIV is opened, clicking same link won't do a thing?

提前谢谢!

推荐答案

使用.one():

$('#cmnt_add').one("click", function () { $('.dark_div_add').slideToggle(1100); });

来自 jQuery的文档:

此外,如果您知道它最初会被隐藏,那么使用.slideDown()而不是.slideToggle()可能是个好主意...

Also, if you know it'll be hidden initially, using .slideDown() instead of .slideToggle() may be a good idea...

这篇关于jQuery slideToggle调用一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 05:42