HTML ontouchmove Event Attribute


The ontouchmove HTML event attribute is used to specify a script to be executed when a user drags their finger across the touch screen while touching an element. It is a standard HTML event that is supported by all modern browsers.

The ontouchmove event is fired once for every movement of the finger, and it continues to fire until the finger is lifted from the touch screen. The event object provides information about the touch, such as the position of the finger, the identifier of the touch, and the number of fingers touching the screen.

The ontouchmove event can be used to create a variety of interactive elements, such as sliders, carousels, and drawing applications. For example, the following code snippet uses the ontouchmove event to update the position of a draggable element:

<div id="draggable" ontouchmove="updatePosition(event)">
  Drag me!

function updatePosition(event) {
  const element = document.getElementById("draggable"); = event.touches[0].clientX + "px"; = event.touches[0].clientY + "px";

In this example, the updatePosition() function is called whenever the user moves their finger while touching the draggable element. The function updates the position of the element based on the current position of the finger.

The ontouchmove event is a powerful tool that can be used to create engaging and interactive web pages. By using this event, developers can create elements that respond to user input in a natural and intuitive way.


<element ontouchmove="script">


  • scriptThe name of the script to use when the event has been triggered.


<p ontouchmove="myFunction(event)">Touch this paragraph, and move the finger to trigger a function that will display the x and y coordinates of the touch, according the the document:</p>

<p><strong>Note:</strong> This example is for touch devices only.</p>

<p id="demo"></p>

function myFunction(event) {
var x = event.touches[0].clientX;
var y = event.touches[0].clientY;
document.getElementById("demo").innerHTML = x + ", " + y;

Browser Support

The following table will show you the current browser support for the HTML ontouchmove Event Attribute.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 21st October 2023