touchstart Event
THE WORLD'S LARGEST WEB DEVELOPER SITE

touchstart Event

❮ DOM Events ❮ TouchEvent

Example

Execute a JavaScript when the user touches a P element (for touch screens only):

<p ontouchstart="myFunction(event)">Touch me!</p>
Try it Yourself »

Definition and Usage

The touchstart event occurs when the user touches an element.

Note: The touchstart event will only work on devices with a touch screen.

Tip: Other events related to the touchstart event are:

  • touchend - occurs when the user removes the finger from an element
  • touchmove - occurs when the user moves the finger across the screen
  • touchcancel - occurs when the touch is interrupted

Browser Support

The numbers in the table specify the first browser version that fully supports the event.

Event
touchstart 22.0 12.0 52 Not supported Not supported


Syntax

In HTML:

<element ontouchstart="myScript">
Try it Yourself »

In JavaScript:

object.ontouchstart = myScript;
Try it Yourself »

In JavaScript, using the addEventListener() method:

object.addEventListener("touchstart", myScript);
Try it Yourself »

Technical Details

Bubbles: Yes
Cancelable: Yes
Event type: TouchEvent
Supported HTML tags: All HTML elements

❮ DOM Events ❮ TouchEvent