简体   繁体   中英

jquery closest selector in text

$(".class1").children(".class2") <=> ".class1 > .class2"
$(".class1").find(".class2") <=> ".class1 .class2"
$(".class1").closest(".class2") <=> ?

Does something like ".class1:closest(.class2)" exist?

.closest goes up the DOM tree, while .children and .find go down it. No, there is no shorthand way to write it as a selector.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM