问题描述
无论如何,在Firefox的querySelector()或querySelectorAll()函数中使用伪选择器来检测可见性?特别是我想能够做到这样的事情: elem.querySelector('#list .list-item:visible );
elem.querySelector('#section .sub-section:visible .title');
不需要担心浏览器不一致或其他的实现,只是Firefox。感谢!
编辑:显示不是 none strong> visibility 不是 hidden 。
没有定义:visible
code>(或相关的)选择器,而且AFAIK Firefox不会执行非标准的伪选择器。
如果你想自己实现这个, jQuery如何实现它的:visible
选择器:
$ b
:
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:
Source: http://docs.jquery.com/Release:jQuery_1.3.2#:visible.2F:hidden_Overhauled
这篇关于Firefox,查询选择器和可见伪选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!