ξσ Dicky's Blog σξ

朋友多了,寂寞卻沒少,朋友沒有了你,得到了天下最高的技術又能如何?人類的全部才能無非是時間和耐心的混合物.---巴尔扎克

Traditional Chinese

导航

innerHTML、outerHTML、innerText、outerText的区别

1.innerHTML Sets or retrieves the HTML between the start and end tags of the object;
2.outerHTML Sets or retrieves the object and its content in HTML;
3.innerText Sets or retrieves the text between the start and end tags of the object;
4.outerText Sets or retrieves the text of the object.

<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);">


运行一下上面的代码就知道区别的所在了^_^

posted on 2005-02-25 21:01  ξσ Dicky σξ  阅读(1191)  评论(5编辑  收藏  举报