JavaScript Error in add method using IE8

2019-03-04 14:12发布

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]);
            }

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

Does anyone knows what can be the error in IE8 ?

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

>> 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]
}

Thank you !

1条回答
放荡不羁爱自由
2楼-- · 2019-03-04 14:41

countryList.add()? I would use countryList.appendChild().

查看更多
登录 后发表回答