jQuery hierarchical selector

Level selector


##$(s1 s2) [Father and Son]

Derived selector: Get all s2 nodes inside s1 (regardless of level)

$("div span")



$(s1 > s2) [parent and child]
##Direct child element selector: in s1 Internally obtain the child element node of s2

$("div > span")



$(s1 + s2) [Brother]
Direct sibling selector: Get the s2 node of the first sibling relationship immediately after s1. There cannot be any other tags between s1 and s2, otherwise Not working

$("div + span")


##$(s1 ~ s2 ) [Brothers]

Subsequent all sibling relationship node selectors: Get all s2 nodes of sibling relationships behind s1

$("div ~ span" )

   php.cn    

层次选择器

北京

上海

深圳

南京

杭州

厦门

天津
重庆
合肥

Note: Please comment out the other three of the four selectors. Test one by one

Continuing Learning
||
php.cn

层次选择器

北京

上海

深圳

南京

杭州

厦门

天津
重庆
合肥
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!