document.getElementById("").innerHTML如何解释啊,为什么有时候可以赋值,有时候不赋值也可以,请大侠详细解释一下,谢谢啊

解决方案 »

  1.   

    document.getElementById("").innerHTML这个是相对哪些什么span、DIV的
    document.getElementById("").value是相对<input type="text">这些控件的,多用就知道了
      

  2.   

    正像楼上所说的。
    你最好把不能赋值的列出来吧。
    有些是用属性.value的。
      

  3.   

    function isIE() { //ie? 
        if (window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1)
            return true;
        else
            return false;
    }
    if (!isIE()) { //firefox innerText define 
        HTMLElement.prototype.__defineGetter__("innerText",
    function () {
        var anyString = "";
        var childS = this.childNodes;
        for (var i = 0; i < childS.length; i++) {
            if (childS[i].nodeType == 1)
                anyString += childS[i].tagName == "BR" ? '\n' : childS[i].textContent;
            else if (childS[i].nodeType == 3)
                anyString += childS[i].nodeValue;
        }
        return anyString;
    }
    );
        HTMLElement.prototype.__defineSetter__("innerText",
    function (sText) {
        this.textContent = sText;
    }
    );
    }不是所以浏览器都是innertext,上次我也遇到过这问题,在你的脚本里加上以上代码再试试