JqueryThe three traversal methods of each, let you see the useful each method injquery, forjqueryIf you are interested, you can collect it and take a look!
1. Selector + traversal
$('div').each(function (i){
i is the index value
this means getting and traversing each DOM object
});
2. Selector + traversal
$('div' ).each(function (index,domEle){
index is the index value
domEle means getting and traversing each dom object
});
3. A more applicable traversal method
1) First obtain a collection object
2) Traverse each element of the collection object
var d =$("div");
$.each(d,function (index,domEle){
d is the collection to be traversed
index is the index value
domEle means to traverse each dom pair
});
The above is a brief description and code demonstration of the three traversal methods of each in Jquery.
Related recommendations:
JQuery simulates click events and automatically triggers events
jquery simulates the title prompt effect
The above is the detailed content of Three traversal methods of each in Jquery. For more information, please follow other related articles on the PHP Chinese website!