JavaScript入门篇:innerText,innerHTML,outerHTML

首先, 需要强调的一点是 innerText  innerHTML是非DOM标准的方法.既然是非标准方法,那么在开发时我们需要考虑在各种浏览器下的不同诠释

在IE下innerText和innerHTML 两个方法都可以正常使用

而FireFox下innerText不可用, 不过FF下可以使用 textContent 方法得到同样的效果.

                              __innerTEXT___
                              |                    | 
                              |                    |

<div id="testDiv">  <p>Some Text In Div </p> </div>
|            |                                          |         |
|            |_____innerHTML________|         |

|_______________outerHTML _________________|

目前innerText outerTEXT在MSDN中的解释为:

outerText provides changes that the system inserts as straight text, without performing any parsing. This text replaces the entire original element, including its HTML tags.

innerText provides changes that the system inserts as straight text, without performing any parsing.


http://www.cnblogs.com/luoluo/archive/2008/11/24/1340111.html

http://www.cnblogs.com/wangyile/archive/2009/04/15/1436796.html

http://www.jb51.net/article/16585.htm

http://msdn.microsoft.com/zh-cn/library/aa241750(en-us,VS.60).aspx

posted @ 2010-03-17 15:30  幻想震  阅读(117)  评论(0编辑  收藏  举报