jQueryにeachを利用する方法

参考コード1
var arr = [ “one", “two", “three", “four"];
$.each(arr, function(){
alert(this);
});

輸出結果:
one,two,three,four

参考コード2
var arr1 = [[1, 4, 3], [4, 6, 6], [7, 20, 9]]
$.each(arr1, function(i, item){
alert(item[0]);
});

輸出結果:
1 4 7

参考コード3
var obj = { one:1, two:2, three:3, four:4};
$.each(obj, function(key, val) {
alert(obj[key]);
});

輸出結果:
1 2 3 4

JavaScript

Posted by arkgame