ontouchend
ontouchend event
The ontouchend
event handler activates a script when a touch point is lifted from the touch surface. It is commonly used to manage the conclusion of touch interactions on mobile devices.
Syntax
In HTML
<element ontouchend="myScript">
In JS
object.ontouchend = myScript;
addEventListener()
function is used. In JavaScript, the
object.addEventListener("touchend", myScript);
Example
<!DOCTYPE html>
<html>
<body>
<h1>DOM touchend Event</h1>
<p ontouchend="myFunction()">Touch this paragraph, then release the touch to trigger a function that will write "Hello World".</p>
<p><strong>Note:</strong> This example is for touch devices only.</p>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
</body>
</html>
Values
Conclusion
The ontouchend
event in HTML is triggered when a touch point is removed from the touch surface, signaling the end of a touch interaction. It's especially useful for responding to gestures such as taps, drag-and-drop actions, or swipes on touch-enabled devices. Developers can use this event to perform actions once a touch gesture is completed, enhancing user interaction.
ontouchcancel
The ontouchcancel event in HTML is triggered when a touch action is interrupted, enabling scripts to react to the cancellation of touch events.
ontouchmove
The ontouchmove event in HTML is triggered when a touch point moves across the touch surface, enabling scripts to respond to the movement of the touch.