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.
Example
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>
Syntax
element.hasPointerCapture(pointerId)
Parameter Values
Value | Type | Explanation |
---|---|---|
pointerId | Required | The pointerId of a PointerEvent object. |
Return Values
Value | Explanation |
---|---|
true | If the element does have pointer capture. |
false | If the element does not have pointer capture. |
Reminder
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.