IntersectionObserver.unobserve()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.
IntersectionObserver
的unobserve()
方法命令IntersectionObserver
停止对一个元素的观察。
语法
js
IntersectionObserver.unobserve(target);
参数
target
-
要取消观察的目标,如果没有提供,方法不做任何事情,也不会抛出异常。
返回值
undefined
.
例子
下面代码段展示了一个观察器被创建,一个元素被观察,以及取消观察的过程。
js
var observer = new IntersectionObserver(callback);
observer.observe(document.getElementById("elementToObserve"));
/* ... */
observer.unobserve(document.getElementById("elementToObserve"));
说明
Specification |
---|
Intersection Observer # dom-intersectionobserver-unobserve |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
unobserve |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.