如何从输入字段中获取插入位置?
我通过谷歌发现了一些零碎的东西,但没有任何防弹措施.
基本上像jQuery插件这样的东西是理想的,所以我可以简单地做
$("#myinput").caretPosition()
Run Code Online (Sandbox Code Playgroud) 我们的应用程序在输入字段上使用selectionStart来确定当用户按下箭头键时是否自动将用户移动到下一个/上一个字段(即,当选择位于文本末尾并且用户按下右箭头时我们移动到下一个字段,否则)
Chrome现在阻止在type ="number"的地方使用selectionStart.它现在抛出异常:
Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not support selection.
Run Code Online (Sandbox Code Playgroud)
见如下:
https://codereview.chromium.org/100433008/#ps60001
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#do-not-apply
有没有办法在type ="number"的输入字段中确定插入符的位置?