小程序如何获取input标签当前焦点的位置?
原生js的实现如下,怎样才能拿到标签的selectStart <html>
<head></head>
<body>
<script>
function getTxt1CursorPosition() {
var oTxt1 = document.getElementById('txt1')
var cursurPosition = -1
cursurPosition = oTxt1.selectionStart
alert(cursurPosition)
}
</script>
<input type="text" id="txt1" value="abcde" onclick="getTxt1CursorPosition()" />
</body>
</html>