JQuery slideToggle() 当前显示/隐藏状态属性?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1133192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQuery slideToggle() current show/hide state property?
提问by Craig Quillen
What is the easiest way to programmatically find the current toggle state of a DOM element when using the slideToggle() function in jquery 1.3.2?
在 jquery 1.3.2 中使用 slideToggle() 函数时,以编程方式查找 DOM 元素的当前切换状态的最简单方法是什么?
I expected there to be a property for this, but I can't seem to find one. Directly checking the CSS display or height seems like a hack, but maybe that's what one is expected to do.
我希望有一个属性,但我似乎无法找到一个。直接检查 CSS 显示或高度似乎是一种黑客行为,但也许这就是人们所期望的。
回答by CalebHC
I think you can do something like this,
我认为你可以做这样的事情,
if($("#panel").is(":hidden"))
{
// do stuff
}