touchstart Event

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

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">

    In JavaScript:

    object.ontouchstart = myScript;

    In JavaScript, using the addEventListener() method:

    object.addEventListener("touchstart", myScript);

    Technical Details

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