To select elements based on their position in the doc tree, use these selectors.
They work by examining the position of target elements relative to other elements.
Yippie!
Examples:
$("parent > child")
: the child selector "parent > child" selects "child" elements that are immediate descendents of the "parent"$("ancestor descendent")
: select "descendent" elements as long as they have an "ancestor" element above them$("prev + next")
: selects the "next" element as long as it is immedatilly preceded by the "prev" element$("prev ~ siblings")
: selects all "siblings" elements that come after a "prev" elementThis is paragraph 1.
This is paragraph 2.
This is paragraph 3.
This is paragraph 4.
This is paragraph 5.