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