js 与jQuery 循环总结

2019-04-15 14:09发布

$("img").each(function(i) { this.src = "images/crm/pic" + i + ".PNG" }); $.each($("img"), function(i, n) { n.src = "images/crm/pic" + i + ".PNG" }) //for (var 变量 in 对象) var imgs = document.getElementsByTagName("img"); //获取img对象 for(i in imgs) { imgs[i].src = "images/crm/pic" + i + ".PNG" } for(var i = 0; i < imgs.length; i++) { imgs[i].src = "images/crm/pic" + i + ".PNG"; }