简体   繁体   English

在Internet Explorer中使用.css('display')==“ none”

[英]using .css('display')==“none” in Internet Explorer

I'm trying to test for something's visibility with 我正在尝试测试某些东西的可见性

$(this).css('display')=="none";

The problem is, it works in chrome, FF...but not in IE. 问题是,它可以在chrome,FF中使用,但在IE中则不能。 I've tried IE 8 and 9 so far. 到目前为止,我已经尝试了IE 8和IE 9。

Does anyone know a work around? 有人知道解决方法吗? This is very frustrating as a bunch of people still use IE and I don't want to lose that bunch of people. 由于很多人仍在使用IE,而我不想失去那一群人,这非常令人沮丧。

Use $(this).is(":visible") for a cross-browser solution. 使用$(this).is(":visible")作为跨浏览器的解决方案。

From the docs: 从文档:

Elements are considered visible if they consume space in the document. 如果元素占用了文档中的空间,则认为它们是可见的。 Visible elements have a width or height that is greater than zero. 可见元素的宽度或高度大于零。

Elements with visibility: hidden or opacity: 0 are considered visible, since they still consume space in the layout. 具有可见性:隐藏或不透明:0的元素被视为可见,因为它们仍然占用布局中的空间。

Read more: http://api.jquery.com/visible-selector/ and How to tell if an element is visible 阅读更多: http : //api.jquery.com/visible-selector/以及如何判断元素是否可见

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM