解决方案 »

  1.   

    你写错了,应该是
    x=document.getElementById("abc").nodeType;
      

  2.   


    var x = document.getElementById("abc")[0].getAttributeNode("id").nodeType;
    alert(x);
      

  3.   

    就是说,标签的属性,不能用.属性名的方式来操作?一定要通过getAtrtribute,或setAttribute方法来操作,是这样子理解吗?还有,你那个“[0]”,是什么意思?
      

  4.   

    <p id=abc></p>
    <script>
    var x = document.getElementById("abc");
    alert(x.id);
    var o = x.getAttributeNode("id");
    alert(o.nodeType +':'+o.nodeName+':'+o.nodeValue);
    </script>
      

  5.   

    document.getElementById("abc").getAttributeNode("id").nodeName  
      

  6.   

    据我所知,用属性名操作获得的是属性名,不是节点,也就没有nodeType这样的属性节点类型了。
    [0]是说去取第一个节点,但是如果用getElementById的话,正常来说只有一个节点,不像使用getElementsByTagName,所以可以去掉。