使用 IE8 添加方法的 JavaScript 错误

JavaScript Error in add method using IE8

本文关键字:JavaScript 错误 方法 IE8 添加 使用      更新时间:2023-09-26

我这里有一段代码,它在FireFox,Chrome和InternetExplorer 9中运行良好,但在InternetExplorer 8中不起作用。我正在处理选择框。

var finalExclusionList = Dom.get("finalExclusionList-box");
            var countryList = Dom.get("regionsAndCountries-box");
            for (var i=0; i<finalExclusionList.length; i++) {
                countryList.add(finalExclusionList[i]);
            }

我在国家列表.add 方法中遇到错误,说参数无效...

有谁知道IE8中的错误是什么?

IE8 - 控制台。.LOG

console.log(countryList) 
LOG: [object HTMLSelectElement]
console.log(countryList[0]) 
LOG: [object HTMLOptionElement]
console.log(finalExclusionList[i]) 
LOG: [object HTMLOptionElement]
console.log(countryList.add) 
LOG: 
function add() {
    [native code]
}

IE9 - 控制台。.LOG

>> console.log(countryList) 
LOG: [object HTMLSelectElement]
>> console.log(countryList[0]) 
LOG: [object HTMLOptionElement]
>> console.log(finalExclusionList[i]) 
LOG: [object HTMLOptionElement] 
>> console.log(countryList.add) 
LOG: 
function add() {
    [native code]
}

谢谢!

countryList.add() ? 我会使用countryList.appendChild().