How can I get the caret position from within an input field?
I have found a few bits and pieces via Google, but nothing bullet proof.
Basically something lik
Use selectionStart, it is compatible with all major browsers.
selectionStart
document.getElementById('foobar').addEventListener('keyup', e => { console.log('Caret at: ', e.target.selectionStart) })
Update: This works only when no type is defined or type="text" on the input.
type="text"