Sizzle Selector Engine Question:
Download Questions PDF

Explain Positional Selector Additions?

Answer:

The word positional here refers to an element's placement in the set after a selection, based on document order. For instance, div:first would return an array containing the first div on the page and div:first em would initially get the first div on the page, then all of the em's within that div. This works by first doing a selection for divs, retrieving the first one from that set, then using that div as the context for finding all em's. Note that all positional selectors are zero-indexed (corresponding to array positions).

:first/:last: Finds the first or last matching element on the page.
:even/:odd: Finds every other element on the page (counting begins at 0, so :even would match the first element).
:eq/:nth: Finds the nth element on the page (e.g. :eq(5) finds the 6th element on the page).
:lt/:gt: Finds all elements at positions less than or greater than the specified positions

Download Sizzle Selector Engine Interview Questions And Answers PDF

Previous QuestionNext Question
Explain Sizzle Selectors?Explain Form Selector Additions?