使用jQuery检查div是否隐藏
这是我的div
<div id="car2" style="display:none;"></div>
然后我有一个显示"按钮,当您单击以下按钮时将显示div:
Then I have a Show button that will show the div when you click:
$("show").click(function() {
$("$car2").show();
});
现在,我想检查在提交表单之前div #car2
是否仍然隐藏:
So right now I want to check if the div #car2
is still hidden before form submission:
if($('#car2').is(':hidden')) {
alert('car 2 is hidden');
}
现在是问题所在.尽管div #car2
已经显示,但我仍然收到警报消息,这意味着jQuery假定div #car2
仍处于隐藏状态.
Now here is the problem. Although the div #car2
already show, I still got alert message which means that jQuery assumes the div #car2
is still hidden.
我的jQuery版本是1.7.
My jQuery version is 1.7.
谢谢.
正如贾斯珀所说,我的代码是正确的,可以通过此演示来运行.
As jasper said, my code is correct and can be run via this demo.
我怀疑与 jquery表单有冲突到我正在与表单一起使用的向导插件.有人有解决这个问题的想法吗?
What i suspect there is some conflict with jquery form to wizard plugin that i am using with my form. Anyone have any idea to solve this?
您可以检查CSS display
属性:
You can check the CSS display
property:
if ($('#car').css('display') == 'none') {
alert('Car 2 is hidden');
}
这是一个演示: http://jsfiddle.net/YjP4K/