Favorites

HTML ongotpointercapture Event Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
ongotpointercapture
HTML Event AttributeThis event attribute is supported by all modern browsers.
Updated 22nd November 2026

Description

The ongotpointercapture event attribute runs a script when an element receives pointer capture, after element.setPointerCapture(pointerId) has been called.

While an element has capture, all events from that pointer are sent to it, even when the pointer moves outside it. This is what makes sliders, drag handles and drawing canvases keep working when the user moves too fast. The event can be used to change the element's appearance while it is being dragged.

Pointer events are a single set of events for all pointing devices: mouse, pen and touch. The event object is a PointerEvent, which extends MouseEvent with properties such as pointerId, pointerType ("mouse", "pen" or "touch"), pressure, width and height. For touch input, the CSS touch-action property controls whether the browser scrolls or zooms the page instead of sending pointer events.

Syntax

<element ongotpointercapture="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html>
<html>
<head>
<title>ongotpointercapture event</title>
<style>
#slider {
width: 300px;
height: 30px;
background: #dde3ff;
touch-action: none;
}
#thumb {
width: 30px;
height: 30px;
background: #4361ee;
}
</style>
</head>
<body>
<div id="slider"><div id="thumb" onpointerdown="this.setPointerCapture(event.pointerId)" ongotpointercapture="log('gotpointercapture')" onlostpointercapture="log('lostpointercapture')"></div></div>
<ul id="log"></ul>
<script>
function log(text) {
var li = document.createElement("li");
li.textContent = text;
document.getElementById("log").appendChild(li);
}
document.getElementById("thumb").onpointermove = function (event) {
if (this.hasPointerCapture(event.pointerId)) {
this.style.marginLeft = Math.max(0, Math.min(270, event.clientX - this.parentNode.getBoundingClientRect().left - 15)) + "px";
}
};
</script>
</body>
</html>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML ongotpointercapture event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.

This event attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee