<script> window.onload = function(){ var xml = new ActiveXObject("Msxml2.DOMDocument") xml.loadXML("<a href=\"www.test.com\"></a>"); node = xml.selectSingleNode("//a/@href"); alert(node.nodeType); //2 } </script>
<a id="link1" href="www.test.com"></a> <script> var a = document.getElemntById('link1'); var href = a.getAttributeNode('href'); alert(href.nodeType) </script>
<script>
window.onload = function(){
var xml = new ActiveXObject("Msxml2.DOMDocument")
xml.loadXML("<a href=\"www.test.com\"></a>");
node = xml.selectSingleNode("//a/@href");
alert(node.nodeType); //2
}
</script>
<script>
var a = document.getElemntById('link1');
var href = a.getAttributeNode('href');
alert(href.nodeType)
</script>
应该这样理解吧