【发布时间】:2013-03-10 17:04:39
【问题描述】:
我有一个 for 循环。
在循环中有一个 if 语句,如果发现下拉列表为空,则添加错误 css 样式。
我的问题是循环仅循环 3 次,然后在应该循环 15 次时停止......并且我不知道为什么。
单独的循环可以正常工作,但是当我添加 if 语句时,它就变得很奇怪了。
帮助。
这是我的循环
//add all the id's in an array. array size is 15
var drop_down=["Cars_chassis","Cars_model".....];
for (var i = 0; i < drop_down.length; i++) {
//check if dropdown is empty
if(document.getElementById(drop_down[i]).value == ""){
//change the color of border
$('#'+drop_down[i]).css('border-color' , '#dddcdc');
}
}
【问题讨论】:
-
你能用你的例子创建一个 jsfiddle 吗?循环似乎没有任何奇怪的东西会导致它中断。
标签: javascript css loops