jquery学习——遍历

1.each()

$(selector).each(function(index,element))

var arr = [ "a", "bb", "ccc" ];      
    $.each(arr,function(i,a){
        console.log(i+":"+a);
    });
//直接对jquery对象遍历
    $(arr).each(function(i,a){
        console.log(i+":"+a);
    });

其中,i是遍历对象的遍历顺序,a是当前遍历对象的值,可以用this代替

 

posted @ 2015-08-27 20:02  fj0716  阅读(111)  评论(0编辑  收藏  举报