【问题标题】:attributes.class.value on Internet Explorer 8Internet Explorer 8 上的 attributes.class.value
【发布时间】:2016-01-14 14:23:24
【问题描述】:

我正在尝试查找具有名为 numberinput 的类的输入标签的总和 IE 8如何支持highligthed(带星号)行? 因为在 Chrome 或 Firefox 上它可以完美运行。

function sum() {
    var elem = document.getElementsByTagName("input");
    var names = [];
    for (var i = 0; i < elem.length; ++i) {
        if (typeof elem[i].attributes.class !== "undefined") {
            **if(elem[i].attributes.class.value === "numberinput")**{
                names.push(elem[i].value);
            }
        }
     }
    var inputValues = names;
    var counter=0;
    for (var i=0; i<inputValues.length; i++){
        counter=inputValues[i]*1+counter;
    }
    document.getElementById("test").innerHTML = counter;
    return counter;
}  

【问题讨论】:

    标签: javascript function class internet-explorer-8 attributes


    【解决方案1】:

    从 IE 2.0 开始,按照 w3schools,这条线应该可以正常工作

    elem[i].attributes.class.value === "numberinput"
    

    您可以放心使用!

    【讨论】:

    • 那么该脚本中是否还有其他内容无法在 IE8 中运行?由于此代码在那里不起作用。不知道为什么。
    猜你喜欢
    • 2011-04-06
    • 2010-10-09
    • 2012-11-26
    • 2010-09-13
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-10
    相关资源
    最近更新 更多