forループ文を使い、2次元配列の要素を、入れ子でリスト表示する方法。
サンプル
<script type="text/javascript">
var $arr = new Array(
[ "要素1-1", "要素1-2", "要素1-3" ],
[ "要素2-1", "要素2-2", "要素2-3" ],
[ "要素3-1", "要素3-2", "要素3-3" ],
[ "要素4-1", "要素4-2", "要素4-3" ],
[ "要素5-1", "要素5-2", "要素5-3" ]
);
document.write( '<ol>\n' );
for ( var $counterVarA = 0; $counterVarA < $arr.length; $counterVarA++ ) {
document.write( '<li>' );
document.write( '<ol>\n' );
for ( var $counterVarB = 0; $counterVarB < $arr[$counterVarA].length; $counterVarB++ ) {
document.write( '<li>' );
document.write( $arr[$counterVarA][$counterVarB] );
document.write( '</li>\n' );
}
document.write( '</ol>' );
document.write( '</li>' );
}
document.write( '</ol>' );
</script>
var $arr = new Array(
[ "要素1-1", "要素1-2", "要素1-3" ],
[ "要素2-1", "要素2-2", "要素2-3" ],
[ "要素3-1", "要素3-2", "要素3-3" ],
[ "要素4-1", "要素4-2", "要素4-3" ],
[ "要素5-1", "要素5-2", "要素5-3" ]
);
document.write( '<ol>\n' );
for ( var $counterVarA = 0; $counterVarA < $arr.length; $counterVarA++ ) {
document.write( '<li>' );
document.write( '<ol>\n' );
for ( var $counterVarB = 0; $counterVarB < $arr[$counterVarA].length; $counterVarB++ ) {
document.write( '<li>' );
document.write( $arr[$counterVarA][$counterVarB] );
document.write( '</li>\n' );
}
document.write( '</ol>' );
document.write( '</li>' );
}
document.write( '</ol>' );
</script>
↓↓↓出力結果↓↓↓