Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Element
  4. hasPointerCapture()

Element: hasPointerCapture() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.

ThehasPointerCapture() method of theElement interface checks whether the element on which it is invoked haspointer capture for the pointer identified by the given pointer ID.

Syntax

js
hasPointerCapture(pointerId)

Parameters

pointerId

ThepointerId of aPointerEvent object.

Return value

A boolean value —true if the element does have pointer capture for the pointer identified by the given pointer ID,false if it doesn't.

Examples

html
<div>Touch this element with a pointer.</div>
js
const el = document.getElementById("target");el.addEventListener("pointerdown", (ev) => {  // Element 'target' will receive/capture further events  el.setPointerCapture(ev.pointerId);  // …  // Check whether element still has pointer capture  const pointerCap = el.hasPointerCapture(ev.pointerId);  if (pointerCap) {    // We've still got pointer capture  } else {    // oops, we've lost pointer capture!  }});

Specifications

Specification
Pointer Events
# dom-element-haspointercapture

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp