"Select all" when the bootstrap button is pressed

Say I have this input:

  <li><input type="text" id="elementHeight" class="form-control" placeholder="Height"> </li>

and I want to "Select All" in the input field when the user clicks on it.

+3
source share
3 answers
$('input').click(function () {
    this.select();
});
+6
source

From a similar question, I got the answer that I prefer.

<input type="text" onfocus="this.select();" onmouseup="return false;" />

Source: fooobar.com/questions/25684 / ...

+4
source

when the field is focused, click

$("#elementHeight").focus(function(){
    this.select();
});
+1
source

All Articles