How can I get the cursor / caret position inside an HTML input element?
1 answer
You would use a property selectionStart
or selectionEnd
element input
.
setInterval(function(){
console.log([document.getElementById("test").selectionStart, document.getElementById("test").
selectionEnd
------------
]);
}, 1000);
<input type="text" id="test"></input>
0
a source to share