Analysis of filter of function and find of function in jQuery
- 2020-06-22 23:45:51
- OfStack
This article illustrates the usage of filter() and find() functions in jQuery. Share to everybody for everybody reference. The specific analysis is as follows:
$("div .cont");
Is equivalent to $(" div "). find (". cont ")
The filter() function is applied to every object in the set ($),
The find() function looks for the child elements of a matching expression within each object
Example:
<div class="cont"><p class="cont">asdf</p></div>
<div><p class="cont">jldf</p></div>
$("div").filter(".cont")// Access is <div class="cont"> The label of the
Means to find the div element with class as cont
$("div").find(".cont")// Access is <p class="cont"> The label of the
After finding div, look for the element with class as cont among the children of div
Hopefully, this article has helped you with your jQuery programming.