概念
DOM(document object model)文档对象模型
整个文档是由一系列的节点对象组成的一棵树
节点:n=Node 节点包括元素节点(1),属性节点(2)和文本节点(3)
<body>
<table>
<tr>
<th id="th1">小伙真帅</th>
</tr>
</table>
<a href="http://www,baidu,com" id="a1" target="_blank" style="font-size: 3em;">百度地址</a>
</body>
<script type="text/javascript">
var th1=document.getElementById("th1")
alert(th1.nodeType);
alert(th1.nodeName);
alert(th1.nodeValue);
th1代表一个元素节点(nodeType=1),nodeName是标签名(th)元素节点的nodeValue=null。
<body>
<table>
<tr>
<th id="th1">小伙真帅</th>
</tr>
</table>
<a href="http://www,baidu,com" id="a1" target="_blank" style="font-size: 3em;">百度地址</a>
</body>
<script type="text/javascript">
var th1=document.getElementById("th1")
//alert(th1.nodeType);
//alert(th1.nodeName);
//alert(th1.nodeValue);
var a1=document.getElementById("a1");
var attr1=a1.