innerHTML 从对象开始到结束的全部内容,包括Html标签
innertext 从对象开始到结束位置的内容, 但它去除Html标签
outerHTML 从对象开始到结束位置的全部内容,除了包含innerHTML的全部内容外, 还包含对象标签本身
<html>
<head>
<script type="text/javascript">
function test()
{
alert(document.getElementById("tr1").innerHTML);
alert(document.getElementById("tr1").innerText);
alert(document.getElementById("tr1").outerHTML);
}
</script>
</head>
<body>
<table border="1">
<tr id="tr1">
<th>aa</th>
<th>bb</th>
</tr>
</table>
<br />
<input type="button" />
</body>
转载于:https://blog.51cto.com/0x007/1217974