blob: c3099ca2242dac6781f4e7582563a3c1e9731e96 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
---
title: IntersectionObserver.unobserve()
slug: Web/API/IntersectionObserver/unobserve
tags:
- API
- Intersection
- unobserve
translation_of: Web/API/IntersectionObserver/unobserve
---
<div><code>unobserve()方法命令</code>IntersectionObserver停止对一个元素的观察。</div>
<h2 id="语法">语法</h2>
<pre class="syntaxbox">IntersectionObserver.unobserve(<em>target</em>);</pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>target</code></dt>
<dd>要取消观察的目标,如果没有提供,方法不做任何事情,也不会抛出异常。</dd>
</dl>
<h3 id="返回值">返回值</h3>
<p><code>undefined</code>.</p>
<dl>
</dl>
<h2 id="例子">例子</h2>
<p>下面代码段展示了一个观察器被创建,一个元素被观察,以及取消观察的过程。</p>
<pre class="brush: js">var observer = new IntersectionObserver(callback);
observer.observe(document.getElementById("elementToObserve"));
/* ... */
observer.unobserve(document.getElementById("elementToObserve"));</pre>
<h2 id="说明">说明</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('IntersectionObserver','#dom-intersectionobserver-unobserve','IntersectionObserver.unobserve()')}}</td>
<td>{{Spec2('IntersectionObserver')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("api.IntersectionObserver.unobserve")}}</p>
<h2 id="另请参阅">另请参阅</h2>
<ul>
<li><a href="/en-US/docs/Web/API/Intersection_Observer_API">Intersection Observer API</a></li>
<li>{{domxref("IntersectionObserver.observe()")}}</li>
</ul>
|