JavaScript element.hasPointerCapture() Method

You are Here:

JavaScript element.hasPointerCapture() Method

The element.hasPointerCapture() method returns a Boolean value indicates whether the element does have pointer capture or not.


HTML Online Editor
<!DOCTYPE html> <html> <body> <button onpointerdown="pointDown(event)" onpointerup="pointerUp(event);">Press Me</button> <p id="point"></p> <script> var x = document.getElementById("point"); var elem = document.getElementsByTagName("button")[0]; function pointDown(e){ elem.setPointerCapture(e.pointerId); check(e); } function pointerUp(e){ elem.releasePointerCapture(e.pointerId); check(e); } function check(e){ if(elem.hasPointerCapture(e.pointerId)) x.innerHTML = "Your mouse pointer is captured"; else x.innerHTML = "Your mouse pointer is released"; } </script> </body> </html>



Parameter Values

pointerIdRequiredThe pointerId of a PointerEvent object.

Return Values

trueIf the element does have pointer capture.
falseIf the element does not have pointer capture.


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author