Home > Web Front-end > JS Tutorial > How to get parent elements, sibling elements, and child elements using jquery selector_jquery

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

WBOY
Release: 2016-05-16 16:48:21
Original
1652 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:








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