现在的位置: 首页 > 综合 > 正文

jquery中.each的实现方法

2013年10月02日 ⁄ 综合 ⁄ 共 156字 ⁄ 字号 评论关闭
Array.prototype.each = function(callback) {

    for(var i=0;i<this.length;i++) {

        callback(i,this[i]);

    }

}


[1,2,3,4].each(function(index,item) {

    alert(index);

    alert(item);


})

 

【上篇】
【下篇】

抱歉!评论已关闭.