What is a traverse?
jQuery traversal, which means "move", according to their relationship with other elements to "Find" (or select) HTML elements. Select an item to begin, and the choice to move along until the elements you expect to arrive.
The figure below shows a family tree. By jQuery traversal, you can choose from the (current) element start, easily move (ancestral) in the family tree upward, downward movement (offspring), horizontal movement (compatriots). This movement is called the DOM traversal.
- <Div> element is the <ul> parent element, which is also the ancestor of all content.
- <Ul> element is the parent element of <li> elements, while the <div> element child
- <Li> element left is the <span> parent element, <ul> child element, while the <div> offspring.
- <Span> element is the <li> child element, while the <ul> and <div> offspring.
- Two <li> elements are siblings (have the same parent element).
- <Li> element on the right is <b> parent element, <ul> child element, while the <div> offspring.
- <B> element is the <li> element to the right of the child, while the <ul> and <div> offspring.
|Ancestors father, grandfather, great-grandfather and so on. Descendant is a child, grandson, great-grandchildren, and so on. Compatriots have the same parent.|
jQuery provides several DOM traversal methods.
Traversal methods largest species is the tree traversal (tree-traversal).
The next chapter will explain how up in the DOM tree, and under similar move.