Search code examples
jqueryvisible

JQuery :visible is not visible to every element except from head?


I attended a test and this assertion was given as false: $(':visible') have access to all visible elements in a document, except the elements from head tag as style, meta, scripts, title etc

Where is the error? Thanks in advance


Solution

  • After quick reading of the documentation:

    Visible elements have a width or height that is greater than zero.

    (...)

    All option elements are considered hidden, regardless of their selected state.

    So these are two quick answers why the statement isn't true (it has no access to elements with width/height equal zero and to all option elements).

    I assume it's not the only reason, but this would be my first guess.