我有一个div
元素<div id='someId' style="visibility: hidden;"></div>
$(#someId)的CSS( '能见度'); //返回“隐藏” $(#someId)。是( ':隐藏'); //返回false $(#someId)。是( ':可见'); //返回true
这是JQuery 1.8中的错误还是我没弄明白?
答案 0 :(得分:3)
:hidden
选择器可以引用:
display: none
type="hidden"
width: 0px; height: 0px
所以visibility: hidden
在这些情况下不会进入。
请参阅此处的jQuery文档:http://api.jquery.com/hidden-selector/
修改强>
检查visibility
属性:
if($("#someId").css('visibility') == 'hidden') {
/* some code */
}
答案 1 :(得分:2)
答案 2 :(得分:1)
来自jquery.com:
Elements can be considered hidden for several reasons:
They have a CSS display value of none.
They are form elements with type="hidden".
Their width and height are explicitly set to 0.
An ancestor element is hidden, so the element is not shown on the page.
答案 3 :(得分:0)
是(':visible')并且是('hidden')将显示属性作为参考