Open In App
Related Articles

HTML | DOM TouchEvent touches Property

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The TouchEvent touches property in HTML DOM is used to return the array of touch object. It returns one for each finger that is currently touching to the surface. The touches property is a read only property and it returns an array of touch objects. 

Syntax:

event.touches

Return Value: It return the array of touch object. 

Below program illustrates the TouchEvent touches property in HTML: 

Example: This example find the number of fingers touch on the surface. 

html

<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM TouchEvent Touches Property
    </title>
</head>
 
<body ontouchstart = "touch(event)" ontouchend = "touch(event)">
 
    <h1>GeeksforGeeks</h1>
     
    <h2>TouchEvent Touches Property</h2>
     
    <p>Number of fingers touching this document:
    <span id="test"></span>.
     
    <!-- script to count number of touch -->
    <script>
        function touch(event) {
            var t = event.touches.length;
            document.getElementById("test").innerHTML = t;
        }
    </script>
</body>
 
</html>                                                 

                    

Output: Before touching the document:

  

After touching the document:

  

Supported Browsers: The browser supported by DOM TouchEvent touches Property are listed below:

  • Google Chrome 22.0 and above
  • Edge 79.0 and above
  • Firefox 52.0 and above
  • Opera 15 and above

Last Updated : 13 Jun, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads