The hasPointerCapture() method of the Element interface indicates whether the element on which it is invoked has pointer capture for the pointer identified by the given pointer ID.
targetElement.hasPointerCapture(pointerId);
identifier for a pointer event.A boolean value — true if the element does have ponter capture, false if it doesn't.
<html>
<script>
function downHandler(ev) {
const el = document.getElementById("target");
// Element 'target' will receive/capture further events
el.setPointerCapture(ev.pointerId);
...
// Check whether element still has pointer capture
let pointerCap = el.hasPointerCapture(ev.pointerId);
if(pointerCap) {
// We've still got pointer capture
} else {
// oops, we've lost pointer capture!
}
}
function init() {
const el = document.getElementById("target");
el.onpointerdown = downHandler;
}
</script>
<body onload="init();">
<div id="target"> Touch me ... </div>
</body>
</html>
| Specification | Status | Comment |
|---|---|---|
| Pointer Events – Level 2 The definition of 'hasPointerCapture()' in that specification. | Working Draft |
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.
No compatibility data found. Please contribute data for "api.Element.hasPointerCapture" (depth: 1) to the MDN compatibility data repository.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/element/hasPointerCapture