Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery get cursor position

Use selectionStart, it is compatible with all major browsers.

document.getElementById('foobar').addEventListener('keyup', e => {
  console.log('Caret at: ', e.target.selectionStart)
})
<input id="foobar" />
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jquery #cursor #position
ADD COMMENT
Topic
Name
3+9 =