📜  jquery 获取光标位置 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:37.205000             🧑  作者: Mango

代码示例1
Use selectionStart, it is compatible with all major browsers.

document.getElementById('foobar').addEventListener('keyup', e => {
  console.log('Caret at: ', e.target.selectionStart)
})