Difference between find and filter

后端 未结 8 957
花落未央
花落未央 2020-12-09 09:19

I have recently jumped into the world of jQuery. I saw the methods find() and filter() but can not figure out the difference between the two.

8条回答
  •  执笔经年
    2020-12-09 09:51

    find()

    find() returns the descendants of the selected elements that match the selector.

    From the doc:

    Description: Get the descendants of each element in the current set of matched elements, filtered by a selector.

    filter()

    filter() filters the elements based on the selector or the provided function.

    From the doc:

    Description: Reduce the set of matched elements to those that match the selector or pass the function's test.

提交回复
热议问题