Home > Web Front-end > JS Tutorial > body text

How to get parent elements, sibling elements, and child elements using jquery selector_jquery

WBOY
Release: 2016-05-16 16:48:21
Original
1616 people have browsed it

1. Get the parent element

1. parent([expr]):

Get all parent elements of the specified element

Copy the code The code is as follows:

href_fir< /a>
href_sec
href_thr< ;/div>

href_fiv

$(document).ready(function(){
$("a").parent().addClass('a_par');
});

firebug view jquery parent effect

2. Get sibling elements:

1. next([expr]):
Get the next sibling element of the specified element (note that it is the next sibling Element)
Copy code The code is as follows:









  • list item 1

  • list item 2

  • list item 3

  • list item 4

  • list item 5



  • Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template