- jQuery Traversing, which Means “Move through”, are used to “find / Search” or Select HTML Elements based on their Relationship to the Other Elements. Start with single Selection & Move through that Selection until You reach Elements that you Desire.
- Below given Picture illustrates a Family Tree. With jQuery Traversing, you could Easily Move-Up (Ancestors), Down (Descendants) & Side-ways (Siblings) in Tree, Starting from the Current HTML Element. This Movement is Called Traversing – or Moving through DOM.
- HTML <div> Element is Parent of <ul> & an Ancestor of Every Thing inside of it.
- HTML <ul> Element is Parent of both <li> Elements & Child of <div> Element.
- HTML left <li> Element is Parent of <span>, Child of <ul> & a Descendant of <div>.
- HTML <span> Element is Child of left <li> & Descendant of <ul> & <div>.
- HTML Two <li> Elements are Siblings. Means that they Share Same Parent.
- HTML Right <li> Element is Parent of <b>, Child of <ul> & Descendant of <div>.
- HTML <b> Element is Child of Right <li> & Descendant of <ul> & <div>.
An Ancestor is a Parent, Grand-Parent, Great-Grand-Parent & so on.
A Descendant is a Child, Grand-Child, Great-Grand-Child & so on.
Siblings Share Same Parent.
- jQuery Provides a huge Variety of Methods that Allows us to Traverse DOM.
- A Largest Category of Traversal Methods are Tree-Traversal.