Set cursor at the end of the input
This commit is contained in:
parent
af29b4c039
commit
1d8b37add1
2 changed files with 4 additions and 1 deletions
|
@ -11,7 +11,7 @@
|
|||
Stoatally different.
|
||||
|
||||
<form action="/search">
|
||||
<input type="search" id="search" name="s" />
|
||||
<input type="search" id="search" name="s" value="" autofocus/>
|
||||
</form>
|
||||
|
||||
<div id="results">
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
window.onload = (event) => {
|
||||
const searchInput = document.getElementById('search');
|
||||
|
||||
const length = searchInput.value.length;
|
||||
searchInput.setSelectionRange(length, length);
|
||||
|
||||
searchInput.addEventListener('keyup', (e) => {
|
||||
console.log(searchInput.value);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue