getElementById()
getElementsByName()
getElementsByTagName()
hasChildNodes()
nodeName
nodeType=1元素节点/2属性节点/3文本节点
nodeValue
1 <script type="text/javascript">
2 //取得input元素的名字 nodeName,类型nodeType值nodeValue;
3 var inputElement=document.getElementById("tid");
4 var nodeName=inputElement.nodeName;
5 var nodeType=inputElement.nodeType;
6 //元素节点的nodeValue返回的是null
7 var nodeValue=inputElement.nodeValue;
8 alert(nodeName+":"+nodeType+":"+nodeValue);
9
10 //取得input元素属性名字nodeName,类型nodeType,nodeValue
11 var inputElement=document.getElementById("tid");
12 var typeAttrElement=inputElement.getAttributeNode("type");
13 var nodeName=typeAttrElement.nodeName;
14 var nodeType =typeAttrElement.nodeType;
15 var nodeValue=typeAttrElement.nodeValue;
16 alert(nodeName+":"+nodeType+":"+nodeValue);
17 </script>
时间: 2024-11-09 08:46:42