Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jquery - Is there an equivalent to .closest() that searches down the DOM tree instead of up?

Is there an equivalent to .closest() that searches down the DOM tree instead of up?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The closest method does actually search down the tree (despite what the documentation says), but I know what you mean. You want one that searches among the children of the element. Depending on how you want to search:

$('#Id').children('div');

or

$('#Id').find('div');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...