MDN self-hosted library · e01.org

Node: selectstart event

Selection API

Selection API

The selectstart event of the Selection API is fired when a user starts a new selection.

If the event is canceled, the selection is not changed.

Syntax

Use the event name in addEventListener():

addEventListener("selectstart", (event) => { })

Alternatively, assign to the event handler property of the interface:

onselectstart = (event) => { }

Event type

A generic Event.

Examples

// addEventListener version
document.addEventListener("selectstart", () => {
  console.log("Selection started");
});

// onselectstart version (but note that this replaces other event listeners
// added using onselectstart, if any)
document.onselectstart = () => {
  console.log("Selection started.");
};

Specifications

Browser compatibility

See also

  • selectionchange