Node: selectstart event
{{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.
addEventListener("selectstart", (event) => { })
onselectstart = (event) => { }
Event type
A generic {{domxref("Event")}}
.
Examples
// 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")}}