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

后端 未结 6 1270
失恋的感觉
失恋的感觉 2020-12-20 11:15

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

6条回答
  •  感情败类
    2020-12-20 11:33

    $('#Id div:first') does also what you are looking for.

    Please also note that while closest() only returns one element, find(), children() and also $("#Id div") returns all matching elements, so you must add .first() or :first to reduce the result to the first occurence.

提交回复
热议问题