Home>
a is placed at the beginning of the input
$('button').on('click', function() {
$('input').focus();
})
<input type="text" value="texttext text"><button class="edit">put focus at the end of the text</button><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
@Igor, they just want to. and it seems logical. or not?
nastya2022-02-12 22:18:14no, it's not logical. Otherwise, when navigating through page elements from the keyboard, this would have been done initially. But, as we can see, when an input receives focus without the help of a mouse, its entire content is selected -the developers did this for a reason.
Инквизитор2022-02-12 22:18:14-
Answer # 1
As an option
$('button').on('click', function() { let inpValue= $('input').val(); $('input').focus().val('').val(inpValue);; })
<input type="text" value="texttext text"><button class="edit">put focus at the end of the text</button><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Related questions
- javascript : Block scrolling by clicking on the arrows
- javascript : Console gives error "Uncaught TypeError: Cannot read properties of null (reading 'style')" [duplicate]
- javascript : How to change the color of the scale in the video?
- javascript : html css + js how to position two charts (Chart_js) side by side rather than one below the other
- javascript : How to highlight one whole line in long HTML text
- javascript : How to emulate safari browser on windows
- javascript : Console throws an error: Uncaught TypeError: Cannot set properties of null (setting 'src')
- javascript : Why won't the animation start?
- javascript : Dropdown menu on click
- javascript : Wrong handler in JS media requests
And why did you decide that he should be put there?
Igor2022-02-12 22:18:14