Element: pointerenter event

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.

The pointerenter event fires when a pointing device is moved into the hit test boundaries of an element or one of its descendants, including as a result of a pointerdown event from a device that does not support hover (see pointerdown). Otherwise, pointerenter works the same as mouseenter, and are dispatched at the same time. They are also dispatched at the same time as mouseover and pointerover events, if appropriate.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("pointerenter", (event) => { })

onpointerenter = (event) => { }

Event type

A PointerEvent. Inherits from Event.

Event UIEvent MouseEvent PointerEvent

Examples

Using addEventListener():

js
const para = document.querySelector("p");

para.addEventListener("pointerenter", (event) => {
  console.log("Pointer entered element");
});

Using the onpointerenter event handler property:

js
const para = document.querySelector("p");

para.onpointerenter = (event) => {
  console.log("Pointer entered element");
};

Specifications

Specification
Pointer Events
# the-pointerenter-event
Pointer Events
# dom-globaleventhandlers-onpointerenter

Browser compatibility

See also