码迷,mamicode.com
首页 > Web开发 > 详细

jQuery.each的function中有哪些参数

时间:2017-03-02 10:57:11      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:back   round   ext   stopped   jquery   name   each   toggle   class   

1、没有参数

$("img").each(function(){
  $(this).toggleClass("example");
});

2、有一个参数,这个参数为index

$("img").each(function(i){
   this.src = "test" + i + ".jpg";
 });

3、有两个参数,第一个参数为index,第二个参数为dom元素本身

$("button").click(function () { 
   $("div").each(function (index, domEle) { 
     // domEle == this 
     $(domEle).css("backgroundColor", "yellow");  
     if ($(this).is("#stop")) { 
        $("span").text("Stopped at div index #" + index); 
        return false; 
     } 
   });
});

jQuery.each的function中有哪些参数

标签:back   round   ext   stopped   jquery   name   each   toggle   class   

原文地址:http://www.cnblogs.com/tongzhou/p/6489265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!