diff options
author | MDN <actions@users.noreply.github.com> | 2021-05-22 00:42:07 +0000 |
---|---|---|
committer | MDN <actions@users.noreply.github.com> | 2021-05-22 00:42:07 +0000 |
commit | 156b518735b8da6cc954105b0a1250ca31449381 (patch) | |
tree | 6a0e35a9622dc00acfc816503410e9a4cd360bc4 /files/zh-cn/web | |
parent | 73aff5bd1edf14df05228693ed569b652ce89eee (diff) | |
download | translated-content-156b518735b8da6cc954105b0a1250ca31449381.tar.gz translated-content-156b518735b8da6cc954105b0a1250ca31449381.tar.bz2 translated-content-156b518735b8da6cc954105b0a1250ca31449381.zip |
[CRON] sync translated content
Diffstat (limited to 'files/zh-cn/web')
-rw-r--r-- | files/zh-cn/web/api/childnode/remove/index.html | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/files/zh-cn/web/api/childnode/remove/index.html b/files/zh-cn/web/api/childnode/remove/index.html deleted file mode 100644 index 001975cd60..0000000000 --- a/files/zh-cn/web/api/childnode/remove/index.html +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: ChildNode.remove() -slug: Web/API/ChildNode/remove -tags: - - API - - ChildNode - - DOM - - Method -translation_of: Web/API/ChildNode/remove ---- -<p>{{APIRef("DOM")}}</p> - -<p><code><strong>ChildNode.remove()</strong></code> 方法,把对象从它所属的 DOM 树中删除。</p> - -<h2 id="语法">语法</h2> - -<pre class="syntaxbox"><var>node</var>.remove();</pre> - -<h2 id="示例">示例</h2> - -<h3 id="使用_remove()">使用 <code>remove()</code></h3> - -<pre class="brush: html"><div id="div-01">Here is div-01</div> -<div id="div-02">Here is div-02</div> -<div id="div-03">Here is div-03</div> -</pre> - -<pre class="brush: js">var el = document.getElementById('div-02'); -el.remove(); -// id 为 'div-02' 的 div 被删掉了 -</pre> - -<p>{{EmbedLiveSample('使用_remove()')}}</p> - -<h3 id="ChildNode.remove()_是不可见的"><code>ChildNode.remove()</code> 是不可见的</h3> - -<p>在 <code>with</code> 语句中,<code>remove()</code> 方法是不可见的。参阅 {{jsxref("Symbol.unscopables")}} 了解更多信息。</p> - -<pre class="brush: js">with(node) { - remove(); -} -// ReferenceError: remove is not defined</pre> - -<h2 id="Polyfill">Polyfill</h2> - -<p>You can polyfill the <code>remove()</code> method in Internet Explorer 9 and higher with the following code:</p> - -<pre class="brush: js">//https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md -(function (arr) { - arr.forEach(function (item) { - if (item.hasOwnProperty('remove')) { - return; - } - Object.defineProperty(item, 'remove', { - configurable: true, - enumerable: true, - writable: true, - value: function remove() { - this.parentNode.removeChild(this); - } - }); - }); -})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);</pre> - -<h2 id="Specification" name="Specification">规范</h2> - -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">规范</th> - <th scope="col">状态</th> - <th scope="col">注释</th> - </tr> - <tr> - <td>{{SpecName('DOM WHATWG', '#dom-childnode-remove', 'ChildNode.remove')}}</td> - <td>{{Spec2('DOM WHATWG')}}</td> - <td>Initial definition.</td> - </tr> - </tbody> -</table> - -<h2 id="浏览器兼容性">浏览器兼容性</h2> - - - -<p>{{Compat("api.ChildNode.remove")}}</p> - -<h2 id="参见">参见</h2> - -<ul> - <li>{{domxref("ChildNode")}} 纯接口。</li> - <li> - <div class="syntaxbox">实现此纯接口的对象类型: {{domxref("CharacterData")}}、{{domxref("Element")}} , 和 {{domxref("DocumentType")}}.</div> - </li> -</ul> |