--- title: IntersectionObserver.unobserve() slug: Web/API/IntersectionObserver/unobserve tags: - API - Intersection - unobserve translation_of: Web/API/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 |
---|---|---|
{{SpecName('IntersectionObserver','#dom-intersectionobserver-unobserve','IntersectionObserver.unobserve()')}} | {{Spec2('IntersectionObserver')}} | Initial definition. |
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.
{{Compat("api.IntersectionObserver.unobserve")}}