document.getElementById(index).value = Node.getAttribute(attr);如果attr属性不存在,getAttribute(attr);返回值是多少??

解决方案 »

  1.   

    手册里都有滴!L@_@K
    Variant. Returns a string, number, or Boolean, defined by sAttrName. If an explicit attribute doesn't exist, an empty string is returned. If a custom attribute doesn't exist, null is returned.要么是空字符串,要么是 null,IsNullOrEmpty!Web 开发常用手册DHTML 参考手册
    http://download.csdn.net/source/308913JScript 语言参考
    http://download.csdn.net/source/308916CCS 样式表中文手册
    http://download.csdn.net/source/304124
      

  2.   

    IE和其他浏览器返回的值不太一样,可以测试下
    <div id="d" class=""></div>
    <script language="javascript" type="text/javascript">
    var div = document.getElementById("d")
    div.innerHTML = "<li>自定义属性mxh = " + div.getAttribute("mxh")
    div.innerHTML += "<li>id 属性 = " + div.getAttribute("id")
    div.innerHTML += "<li>style 属性= " + div.getAttribute("style")
    div.innerHTML += "<li>class 属性 = " + div.getAttribute("class")
    </script>