javascript focus input end of text code example
Example 1: move cursor to end of line javascript
<input type="text" id="yourId" onfocus=" let value = this.value; this.value = null; this.value=value" name="nameYouWant" class="yourClass" value="yourValue" placeholder="yourPlaceholder...">
<script>
document.getElementById("yourId").focus()
</script>
Example 2: jquery focus input end of text
<input type="text" id="Search" value="Hello" />
var searchInput = $('#Search');
var strLength = searchInput.val().length * 2;
searchInput.focus();
searchInput[0].setSelectionRange(strLength, strLength);
Example 3: js vanilla set cursor to edit text on click
element.focus()