jQuery.each的function中有哪些参数


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; } }); });


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM