Back to Content

Node: selectstart event

files/en-us/web/api/node/selectstart_event/index.md

latest904 B
Original Source

{{APIRef("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 methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.

js-nolint
addEventListener("selectstart", (event) => { })

onselectstart = (event) => { }

Event type

A generic {{domxref("Event")}}.

Examples

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

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

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("Document/selectionchange_event", "selectionchange")}}