innerHTML、outerHTML、innerText、outerText的区别
运行以下代码仔细观看一下结果就知道它们的区别了!
<div id="div"><input name="button" value="Button" type="button"><font color="green"><h2>This is a DIV!</h2></font></div>
<input name="innerHTML" value="innerHTML" type="button" onClick="alert(div.innerHTML);">
<input name="outerHTML" value="outerHTML" type="button" onClick="alert(div.outerHTML);">
<input name="innerText" value="innerText" type="button" onClick="alert(div.innerText);">
<input name="outerText" value="outerText" type="button" onClick="alert(div.outerText);">
<div id="div"><input name="button" value="Button" type="button"><font color="green"><h2>This is a DIV!</h2></font></div>
<input name="innerHTML" value="innerHTML" type="button" onClick="alert(div.innerHTML);">
<input name="outerHTML" value="outerHTML" type="button" onClick="alert(div.outerHTML);">
<input name="innerText" value="innerText" type="button" onClick="alert(div.innerText);">
<input name="outerText" value="outerText" type="button" onClick="alert(div.outerText);">