Home > Web Front-end > JS Tutorial > Introduction to the difference between jquery hierarchical selector siblings and nextAll_jquery

Introduction to the difference between jquery hierarchical selector siblings and nextAll_jquery

WBOY
Release: 2016-05-16 17:27:03
Original
1120 people have browsed it

HTML code:

Copy code The code is as follows:


< div >1


2
2_1
2_1_1

< /div>
2_2


3

4


$(".one div").css("background","red") // All DIV descendant elements after .one (descendents: including sons and grandsons...)
$(".one > div").css("background","red") // Child elements after .one. (Son: son and daughter....)
$(".one div").css("background","red") // Adjacent elements after .one. It is the sibling element immediately after .one. There is only one
$(".one").next().css("background","red") // This function is the same as above
$(".one ~ div").css("background" ,"red") //The sibling element after .one. Excluding the previous
$(".one").nextAll().css("background","red") //The function is the same as above
$(".one").siblings().css( "background","red") // All sibling elements of .one, whether they are behind or in front.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template