JQuery difference between searching 'children' and 'find'?

后端 未结 3 888
Happy的楠姐
Happy的楠姐 2021-01-07 19:16

When is one preferred over the other when searching for nested Divs?

3条回答
  •  甜味超标
    2021-01-07 19:49

    Find is recursive, where children looks only 1 level deep in the DOM. Check out this: http://blog.ekini.net/2009/03/16/jquery-children-vs-find-which-is-faster/

    Note: that is actually references a Stackoverflow post.

    Either way, that should help answer your question. If you need to search more than one level use Find, if not use children as it is faster.

提交回复
热议问题