jQuety遍历数组

        var arry = [1, 2, 3, 4];
        var arry2 = $.map(arry, function (item) { return item * item; });
        var obj = {
          "pro1":"11",
          "pr02":"22"
        };
        $.each(arry2, function () { document.writeln(this); });

        $.each(arry2, function (key, value) { document.writeln(key + ":" + value); });

        $.each(obj, function (key, value) { document.writeln(key + ":" + value); });

普通数组key就是下标,value是值,一般使用无参数处理函数

对象用key,value处理函数

posted @ 2012-03-17 19:34  Bug山Bug海  阅读(179)  评论(0编辑  收藏  举报