【问题标题】:JavaScript Error in add method using IE8使用 IE8 的 add 方法中的 JavaScript 错误
【发布时间】:2023-04-03 06:01:01
【问题描述】:

我有一段代码在 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]);
            }

我在 countryList.add 方法中有错误,说 Invalid Argument ...

有谁知道 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]
}

谢谢!

【问题讨论】:

    标签: javascript internet-explorer-8 invalid-argument


    【解决方案1】:

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

    【讨论】:

    • 不客气 - 在 StackOverflow,您通过投票表示感谢。选择我的答案并给我投票!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-31
    • 2010-11-09
    相关资源
    最近更新 更多