Skip to main content
Removed fluff. Rejects https://stackoverflow.com/review/suggested-edits/29982392 which didn't remove the fluff.
Source Link
Wai Ha Lee
  • 8.9k
  • 102
  • 61
  • 100

useUse this. it is simple.:

var textInput = document.querySelector("input"); textInput.onclick = function() { textInput.selectionStart = 0; textInput.selectionEnd = textInput.value.length; }
<input type="text">

it worked! 👍 just try!

use this. it is simple.

var textInput = document.querySelector("input"); textInput.onclick = function() { textInput.selectionStart = 0; textInput.selectionEnd = textInput.value.length; }
<input type="text">

it worked! 👍 just try!

Use this:

var textInput = document.querySelector("input"); textInput.onclick = function() { textInput.selectionStart = 0; textInput.selectionEnd = textInput.value.length; }
<input type="text">

Source Link

use this. it is simple.

var textInput = document.querySelector("input"); textInput.onclick = function() { textInput.selectionStart = 0; textInput.selectionEnd = textInput.value.length; }
<input type="text">

it worked! 👍 just try!