为什么load()函数循环几乎23次,当时我只有8个带.image类的元素
$(document).ready(function()
{
var i=0;
$('.image').load(function(){
console.log(i++);
});
});
我的HTML是
<div class="pel homepics">
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
<div class="left i1" ><a href="#" ><img class="image" src="image1.png"/></a></div>
</div>
答案 0 :(得分:0)
$(document).ready(function()
{
$.each($('.image'),function(i,ele){
$(ele).load(function(){
alert(ele.attr("title")+" loaded");
});
});
});