jquery.each method
Method one
$("img").each(function(i,elem){ // i 下标 从零开始, // elem == this // $(elem).toggleClass("example"); $(this).toggleClass("example"); });
Method two
$.each([1,2,3,4],function(){ //$(this)==数组中的每一个数组(如果数组是对象,就是对象) });
Method three
The scene should be a little different
this.each(function(){ })
Extended jQuery object method
should be
jQuery.fn.Fun=function(){ //this==$("img") 和下面的调用方法相结合,如果是其他对象就是其他对象 this.each(function(){ $(this)==$("img")[0], //$(this)==$("img")[1], // ....... }) } 调用 $("img").Fun();
The above is a brief discussion of the each method $.each and this.each in jquery brought to you by the editor , all the contents of $.fn.each, I hope everyone will support the PHP Chinese website~
Please pay attention to more related articles about the each method in jquery $.each, this.each, $.fn.each PHP Chinese website!