Example 1 — Log pointerenter (MDN)
MDN’s basic listener when a pointer enters an element.
const para = document.querySelector("p");
para.addEventListener("pointerenter", (event) => {
console.log("Pointer entered element", event.pointerType);
}); How It Works
- Listen on an element that should react when entered.
- Handler runs when the pointer crosses into its hit test (MDN).
- Read
pointerTypeto know mouse vs touch vs pen. - Does not re-fire for moves among descendants.

