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('#section .sub-section:visible .title');
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
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.