It's quite easy to select the content of an input field or a textarea whenever it's clicked or focus. You just simply call select() method in the onclick and onfocus event handlers of the input/textarea element. The function of select() method is to select the content of the element.
Below is the sample HTML code.
<input name="textBox1" id="textBox1" value="This text will be select, it is clicked." onclick="javascript: this.select();" onfocus="javascript: this.select();" type="input" />
Post new comment