Chapter 2 Selecting
Custom jQuery filters can select elements when used alone
It is not necessary to provide an actual element in conjunction with a filter, such as
$('div:hidden'). It is possible to simply pass the filter alone, anywhere a selector expression
is expected.
Some examples:
// Selects all hidden elements
$(':hidden');
// Selects all div elements, then selects only even elements
$('div').filter(':even');
Grokking the :hidden and :visible filter
The custom jQuery selector filters :hidden and :visible do not take into account the CSS
visibility property as one might expect. The way jQuery determines if an element is hidden or
visible is if the element consumes any space in the document. To be exact, an element is visible
if its browser-reported offsetWidth or offsetHeight is greater than 0. That way, an element
that might have a CSS display value of block contained in an element with a display value
of none would accurately report that it is not visible.
Examine the code carefully and make sure you understand why the value returned is true even
though the
being selected has an inline style of display:block.
Sample: sample22.html