From a02f4b2f60c81e09b318a090e5c9c2d2d641c878 Mon Sep 17 00:00:00 2001 From: t7yang Date: Sat, 17 Jul 2021 16:10:02 +0800 Subject: replace wiki links in zh-CN --- files/zh-cn/web/api/node/textcontent/index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'files/zh-cn/web/api/node') diff --git a/files/zh-cn/web/api/node/textcontent/index.html b/files/zh-cn/web/api/node/textcontent/index.html index 1a2cd275e7..d9b4f26e86 100644 --- a/files/zh-cn/web/api/node/textcontent/index.html +++ b/files/zh-cn/web/api/node/textcontent/index.html @@ -13,7 +13,7 @@ translation_of: Web/API/Node/textContent

{{domxref ("Node")}} 接口的 textContent 属性表示一个节点及其后代的文本内容。

-

注意: textContent 和 {{domxref("HTMLElement.innerText")}} 容易混淆,但这两个属性在重要方面有不同之处 。

+

注意: textContent 和 {{domxref("HTMLElement.innerText")}} 容易混淆,但这两个属性在重要方面有不同之处 。

语法

@@ -30,13 +30,13 @@ translation_of: Web/API/Node/textContent

textContent 的值取决于具体情况:

@@ -50,7 +50,7 @@ translation_of: Web/API/Node/textContent
  • textContent 会获取所有元素的内容,包括 {{HTMLElement("script")}} 和 {{HTMLElement("style")}} 元素,然而 innerText 只展示给人看的元素。
  • textContent 会返回节点中的每一个元素。相反,innerText 受 CSS 样式的影响,并且不会返回隐藏元素的文本,
  • 与 textContent 不同的是, 在 Internet Explorer (小于和等于 11 的版本) 中对 innerText 进行修改, 不仅会移除当前元素的子节点,而且还会永久性地破坏所有后代文本节点。在之后不可能再次将节点再次插入到任何其他元素或同一元素中。
  • @@ -60,7 +60,7 @@ translation_of: Web/API/Node/textContent

    正如其名称,{{domxref("Element.innerHTML")}} 返回 HTML。通常,为了在元素中检索或写入文本,人们使用 innerHTML。但是,textContent 通常具有更好的性能,因为文本不会被解析为HTML。

    -

    此外,使用 textContent 可以防止 XSS 攻击

    +

    此外,使用 textContent 可以防止 XSS 攻击

    例子

    -- cgit v1.2.3-54-g00ecf