当我用 for 循环循环这个数组时,它以某种方式给了我 undefined in
updateField(this.value, vehicles[i]+"_brand"
尽管
$("#"+vehicles[i]+"_year").change(function(){
确实获得了数组的正确值。这怎么可能,我该如何解决?
var vehicles = new Array();
vehicles[0] = "auto";
vehicles[1] = "truck";
vehicles[2] = "motor";
for(var i = 0;i < vehicles.length;i++){
$("#"+vehicles[i]+"_year").change(function(){
updateField(this.value, vehicles[i]+"_brand", 1, 2, this.parentNode.id), resetBelow(0,'auto'), show('auto_brand');
});
}