代码如下:
mydd = $('.plist');
mydd.each(function(i){
$(this).click(function(){
//mydl.eq(i).hide("slow");
mydd.eq(i).css("background","url(images/m_1281702690741.gif) -1px center no-repeat;");
})
});
注意:此处 this 指代的是 DOM 对象而非 jQuery 对象。
如果遍历的是图片,你就可以用以下的方式:
this.src = “test” + i + “.jpg”;