Firefox,查询选择器和可见伪选择器 [英] Firefox, query selector and the visible pseudo selector
问题描述
elem.querySelector('#list .list-item:visible );
elem.querySelector('#section .sub-section:visible .title');
不需要担心浏览器不一致或其他的实现,只是Firefox。感谢!
编辑:显示不是 none strong> visibility 不是 hidden 。
CSS规范没有定义:visible
code>(或相关的)选择器,而且AFAIK Firefox不会执行非标准的伪选择器。
如果你想自己实现这个, jQuery如何实现它的:visible
选择器:
$ b
在jQuery 1.3.1旧的)如果一个元素的CSSdisplay不是none,它的CSSvisibility不是隐藏,并且它的类型(如果它是一个输入的话)不是隐藏的,那么这个元素是可见的。
在jQuery 1.3.2中,如果浏览器报告的offsetWidth或offsetHeight大于0,则元素是可见的。
: http://docs.jquery.com/Release:jQuery_1.3.2 #:visible.2F:hidden_Overhauled
Is there anyway to use a pseudo selector with Firefox's querySelector() or querySelectorAll() functions to detect visibility? In particular I want to be able to do something like this:
elem.querySelector('#list .list-item:visible');
elem.querySelector('#section .sub-section:visible .title');
No need to worry about browser inconsistencies or other implementation, just Firefox. Thanks!
EDIT: Visible is defined by display not being none and visibility not being hidden.
No, there isn't. The CSS specification doesn't define a :visible
(or related) selector, and AFAIK Firefox doesn't implement non-standard pseudo selectors.
If you'd like to implement this yourself, note how jQuery implements its :visible
selector:
In jQuery 1.3.1 (and older) an element was visible if its CSS "display" was not "none", its CSS "visibility" was not "hidden", and its type (if it was an input) was not "hidden". In jQuery 1.3.2 an element is visible if its browser-reported offsetWidth or offsetHeight is greater than 0.
Source: http://docs.jquery.com/Release:jQuery_1.3.2#:visible.2F:hidden_Overhauled
这篇关于Firefox,查询选择器和可见伪选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!