HTML | DOM onselect Event

The onselect event in HTML DOM occurs when user selects some text in an element. This event is mostly used in <textarea> and <input> tag.

Syntax:

  • In HTML:
    <element onselect="Script">
  • In JavaScript:
    object.onselect = function(){Script};
  • In JavaScript, using the addEventListener() method:
    object.addEventListener("select", Script);