What is fastest children() or find() in jQuery?

前端 未结 6 2005
悲&欢浪女
悲&欢浪女 2020-11-22 13:43

To select a child node in jQuery one can use children() but also find().

For example:

$(this).children(\'.foo\');

gives the same result

6条回答
  •  渐次进展
    2020-11-22 14:34

    Both find() and children() methods are used to filter the child of the matched elements, except the former is travels any level down, the latter is travels a single level down.

    To simplify:

    1. find() – search through the matched elements’ child, grandchild, great-grandchild... all levels down.
    2. children() – search through the matched elements’ child only (single level down).

提交回复
热议问题