SoFunction
Updated on 2025-04-03

How to select text by clicking js

This article example describes the method of selecting text by clicking on js. Share it for your reference. The specific implementation method is as follows:

function selectText() {
  if () {
    var range = ();
    (('copy'));
    ();
  } else if () {
    var range = ();
    (('copy'));
    ().addRange(range);
  }
}

I hope this article will be helpful to everyone's JavaScript programming.