JavaScript Error in add method using IE8

依然范特西╮ 提交于 2020-02-16 10:12:36

问题


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:


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



来源:https://stackoverflow.com/questions/11231543/javascript-error-in-add-method-using-ie8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!