Let's 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.
Let's 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.
From a similar question, I got an answer I prefer.
<input type="text" onfocus="this.select();" onmouseup="return false;" />
when the field is focused ,clicked
$("#elementHeight").focus(function(){
this.select();
});
As of Bootstrap 5, there's user-select-all
, but it wasn't working for inputs so I added this to my script and it works like a charm:
$(".user-select-all").focus(function () {
$(this).select();
});