使用IE8添加方法时出现JavaScript错误

问题描述:

我在这里有一段代码在FireFox,Chrome和InternetExplorer 9中正常工作但在InternetExplorer 8中无效。我正在处理选择框。

I have a piece of code here which is working fine in FireFox, Chrome and InternetExplorer 9 but is not working in the InternetExplorer 8. I'm dealing with select boxes.

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

我在countryList.add方法中遇到错误,说无效参数...

I'm having error in the countryList.add method, is saying Invalid Argument ...

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

Does anyone knows what can be the error in IE8 ?

IE8 - CONSOLE.LOG

IE8 - CONSOLE.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 - CONSOLE.LOG

IE9 - CONSOLE.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 。新增()?我会使用 countryList.appendChild()