innerHTML:设置或返回表格行的开始和结束标签之间的 HTML
innerText:以字符串的形式输出开始和结束标签之间的 HTML
outerHTML:输出包括HTML标签的内容
outerText:输出标签里的内容,不包括标签
<script language="javascript">
function a()
{
alert(tdtd.outerHTML);
}
function b()
{
alert(tdtd.outerText);
}
function c()
{
tdtd.innerHTML="<input type='button' value='123'>";
}
function d()
{
tdtd.innerText="<input type='button' value='123'>";
}
</script>
<br>
<input type="button" value="outerHTML" οnclick="a()" <br>
--->弹出的对话框里面的内容是"<td id="tdtd"><input type='button' value='hh'> </td>"
<input type="button" value="outerText" οnclick="b()" <br>
--->弹出的对话框里面没有内容,因为只能输出标签外的东西
<input type="button" value="innerHTML" οnclick="c()"
--->button上的值"hh"改为"123"
<input type="button" value="innerText" οnclick="d()"
--->button上的值"hh"改为"<input type='button' value='123'>"
<table border=1>
<tr>
<td id="tdtd">
<input type='button' value='hh'>
</td>
</tr>
</table>
紫色头发:http://zisetoufa.iteye.com/
innerText:以字符串的形式输出开始和结束标签之间的 HTML
outerHTML:输出包括HTML标签的内容
outerText:输出标签里的内容,不包括标签
<script language="javascript">
function a()
{
alert(tdtd.outerHTML);
}
function b()
{
alert(tdtd.outerText);
}
function c()
{
tdtd.innerHTML="<input type='button' value='123'>";
}
function d()
{
tdtd.innerText="<input type='button' value='123'>";
}
</script>
<br>
<input type="button" value="outerHTML" οnclick="a()" <br>
--->弹出的对话框里面的内容是"<td id="tdtd"><input type='button' value='hh'> </td>"
<input type="button" value="outerText" οnclick="b()" <br>
--->弹出的对话框里面没有内容,因为只能输出标签外的东西
<input type="button" value="innerHTML" οnclick="c()"
--->button上的值"hh"改为"123"
<input type="button" value="innerText" οnclick="d()"
--->button上的值"hh"改为"<input type='button' value='123'>"
<table border=1>
<tr>
<td id="tdtd">
<input type='button' value='hh'>
</td>
</tr>
</table>
紫色头发:http://zisetoufa.iteye.com/