W3cubDocs

/Web APIs

Node: selectstart event

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 methods like addEventListener(), or set an event handler property.

js

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

onselectstart = (event) => {};

Event type

A generic Event.

Examples

js

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

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

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
selectstart_event 1 12 52 5 15 1.3 4.4 18 52 14 No 1.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/selectstart_event