// With HTML <input type="text" onselect="myFunction()"> // With Javascript object.addEventListener("select", myScript);