整数と文字列の両方のインデックスを持つ配列があります。
何らかの理由で、$。eachが文字列インデックスを正しく反復していないようです。
以下の出力は次のとおりです。
idx:0 1 2 3
idx:1 4 5 6
idx:2 7 8 9
//実際のidx:3 a b c
//予想されるidx:abc 10 11 12
これが私がテストしたコードです:
<html>
<head>
<title>jQuery - each</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var a = new Array();
a.push(0);
a[0] = [1, 2, 3];
a.push(1);
a[1] = [4, 5, 6];
a.push(2);
a[2] = [7, 8, 9];
a.push("abc");
a["abc"] = [10, 11, 12];
$.each(a, function (idx, v) {
alert("idx: " + idx);
alert(v[0]);
alert(v[1]);
alert(v[2]);
});
});
</script>
</head>
<body>
</body>
ご助力ありがとうございます、
リチャードヒューズ