aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/mutationobserverinit/childlist/index.html
blob: 71574b7cea90fdb943f0d8d0908b1fb1dbf809b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: MutationObserverInit.childList
slug: Web/API/MutationObserverInit/childList
translation_of: Web/API/MutationObserverInit/childList
---
<div>{{APIRef("DOM WHATWG")}}</div>

<p><span class="seoSummary">The <strong>{{domxref("MutationObserverInit")}}</strong> dictionary's optional <strong><code>childList</code></strong> property indicates whether or not to monitor the specified node or nodes for the addition or removal of new child nodes.</span></p>

<p>If <code>childList</code> is <code>false</code> (the default), adding or removing new nodes does not trigger mutation callbacks. By setting <code>childList</code> to <code>true</code>, your callback will be invoked any time nodes are added to or removed from the DOM node or nodes being watched.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">var <em>options</em> = {
  <em>childList</em>: true | false
}
</pre>

<h3 id="Value">Value</h3>

<p>A Boolean value indicating whether or not to invoke the callback function when new nodes are added to or removed from the section of the DOM being monitored.. If {{domxref("MutationObserverInit.subtree", "subtree")}} is <code>false</code>, only the node indicated by the observer's target node is monitored for changes. Setting <code>subtree</code> to <code>true</code> causes addition or removal of nodes anywhere within the subtree rooted at <code>target</code> to be reported.</p>

<h2 id="Example">Example</h2>

<h2 id="Specifications" name="Specifications">Specifications</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('DOM WHATWG', '#dom-mutationobserverinit-childlist', 'MutationObserverInit.childList')}}</td>
   <td>{{ Spec2('DOM WHATWG') }}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>


<p>{{Compat("api.MutationObserverInit.childList")}}</p>
</div>