IntersectionObserver.unobserve()
unobserve()方法命令
IntersectionObserver停止对一个元素的观察。语法
IntersectionObserver.unobserve(target);
参数
target
- 要取消观察的目标,如果没有提供,方法不做任何事情,也不会抛出异常。
返回值
undefined
.
例子
下面代码段展示了一个观察器被创建,一个元素被观察,以及取消观察的过程。
var observer = new IntersectionObserver(callback);
observer.observe(document.getElementById("elementToObserve"));
/* ... */
observer.unobserve(document.getElementById("elementToObserve"));
说明
Specification | Status | Comment |
---|---|---|
Intersection Observer IntersectionObserver.unobserve() |
Working Draft | Initial definition. |
浏览器兼容性
BCD tables only load in the browser
The compatibility table in 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.