-1

我用这样的javascript写了一段代码,

                        alert(attributes.length);
                        for(temp=0;temp<attributes.lenth;temp++){
                            attribute_list+="<option value='"+attributes[temp]+"'>"+attributes[temp]+"</option>";
                            if(temp==0)
                                alert(attributes[temp]);
                        }
                        attribute_list+="</select>";
                        alert(attribute_list);

第一个警报显示长度为 58(即属性数组的长度)但控件未进入 for 循环

4

1 回答 1

0

你为什么不检查它自己的循环?

alert(attributes.length);
for(temp=0;temp<attributes.lenth;temp++){

/* test the loop */
console.log(attributes.length);

}

如果控制台日志显示与属性长度一样长,则其平均循环运行良好。所以你必须检查循环内的过程。

于 2012-09-05T07:42:31.170 回答