Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 迭代与对象键嵌套的数组 var html={ easyBB: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'], easyBB2: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb2: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'], easyBB3: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb3: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'] }; var cont=document.getElementById('container'); for(html中的var键){ for(var i=0;ifor(var i=0;i_Javascript_Arrays_Loops_Object - Fatal编程技术网

Javascript 迭代与对象键嵌套的数组 var html={ easyBB: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'], easyBB2: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb2: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'], easyBB3: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb3: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'] }; var cont=document.getElementById('container'); for(html中的var键){ for(var i=0;ifor(var i=0;i

Javascript 迭代与对象键嵌套的数组 var html={ easyBB: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'], easyBB2: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb2: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'], easyBB3: ['EasyBButorials','www.easyBButorials.com','http://i76.servimg.com/u/f76/17/83/35/07/easybb10.png'], AvacWeb3: ['AvacWeb','www.AvacWeb.com','http://i45.servimg.com/u/f45/16/35/08/55/new_lo12.png'] }; var cont=document.getElementById('container'); for(html中的var键){ for(var i=0;ifor(var i=0;i,javascript,arrays,loops,object,Javascript,Arrays,Loops,Object,您应该使用html[key][i][0]。 你也应该按照特雷弗说的做,html[key].length而不是key.length 通过将html[key]分配给var currentkey使自己变得容易,例如,更容易跟踪 另外,查看array.forEach,只是为了好玩;)您应该使用html[key][i][0]。 你也应该按照特雷弗说的做,html[key].length而不是key.length 通过将html[key]分配给var currentkey使自己变得容易,例如,更容易跟踪 另

您应该使用html[key][i][0]。
你也应该按照特雷弗说的做,html[key].length而不是key.length

通过将html[key]分配给var currentkey使自己变得容易,例如,更容易跟踪


另外,查看array.forEach,只是为了好玩;)

您应该使用html[key][i][0]。
你也应该按照特雷弗说的做,html[key].length而不是key.length

通过将html[key]分配给var currentkey使自己变得容易,例如,更容易跟踪


另外,看看array.forEach,只是为了好玩;)

问题不在于迭代,而在于行

for(var i = 0; i < html[key].length; i++){
...
每次循环迭代时都会替换内容,这样您就只能看到最后一项(“AvacWeb3”)

换成

cont.innerHTML = ...

然后去掉不需要的(
for(var i=0…
循环)。

问题不在于迭代,而在于行

for(var i = 0; i < html[key].length; i++){
...
每次循环迭代时都会替换内容,这样您就只能看到最后一项(“AvacWeb3”)

换成

cont.innerHTML = ...

去掉不需要的
for(var i=0…
循环。(

html['easyBB'][0]
html.easyBB[0]
看起来你只需要去掉内部for循环…
html['easyBB'][0]
html.easyBB[0]
看起来你只需要去掉你的内部for循环……叮叮叮叮,我们赢了!谢谢你,哈哈,我真是个笨蛋,我添加了for循环,因为我自己就有了常规的for,我从来没有想过要看innerHTML!我正试着编写纯JS,我先学会了jQuery,所以总是使用
.append
谢谢Stuart!叮叮,叮叮,我们赢了!谢谢你,哈哈,我真是个笨蛋,我添加了for循环,因为我自己有了常规的for,我从来没有想过要看内部的HTML!我只是想写纯JS,我先学会了jQuery,所以总是使用
,它把我甩了。append
谢谢Stuart!