Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery Traversing

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 596
    Comment on it

    Traversing means to select HTML element on the basis of their relationship with other elements. Begining with one element we move through the DOM(Document object Model) untill we achieve the element needed.

    As we shift from one element to another in the DOM, sometimes we are replacing the first choice with new choice, or sometimes we are making choice from the first selection.

    In jQuery there are various methods to traverse the DOM.

    jQuery is having impressive ways which are straightforward and immediate to find an element which we are searching for and helps in acheiving the result we want.

    There are various methods of traversing, one of them is tree-traversal.

    1. children():-

    The children() will return all the immediate children of the selected element.
    This method only traverse a single level down the DOM tree.

    Here is the link for the clear understanding of the children method:-

    https://jsfiddle.net/2rf6qwuo/9/

     

    2. parent():-

    The parent method returns only the immediate parent of the selected element.

    Here is the link for the clear understanding of the parent method:-

    https://jsfiddle.net/tw4ddy1e/6/

     

    3. parents():-

    The parents method returns all parents of the selected element whether direct or indirect.

    Here is the link for the clear understanding of the parents method:-

    https://jsfiddle.net/cnw0k66u/1/

     

    4. parentsUntil():-

    The parentsUntil method get the ancestors of elements upto the described parent.

    Here is the link to explain parentsUntil method:-

    https://jsfiddle.net/xad9cqfg/

     

    5. siblings():-

    The siblings method get all siblings of the selected element.

    Here is the link to explain siblings method:-

    https://jsfiddle.net/h9z0uznz/3/

     

    6. nextUntil():-

    The nextUntil method get all next sibling elements upto described element.

    Here is the link to explain nextUntil method:-

    https://jsfiddle.net/nyz9hk8v/2/

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: