Javascript DOM touchend Event via addEventListener() method

Introduction

In JavaScript, using the addEventListener() method:

object.addEventListener("touchend",
       myScript);

This example is for touch devices only.

View in separate window

<!DOCTYPE html>
<html>
<body>
<p id="myP">
Touch this paragraph, and release the touch to trigger a function that will write "Hello World".</p>
<p id="demo"></p>

<script>
document.getElementById("myP").addEventListener("touchend", myFunction);

function myFunction() {/*  w ww . j ava 2  s .c o m*/
  document.getElementById("demo").innerHTML = "Hello World";
}
</script>

</body>
</html>
Bubbles: Yes
Cancelable: Yes
Event type: TouchEvent
Supported HTML tags: All HTML elements



PreviousNext

Related