我知道这可以通过使用 window.getSelection() 方法在 javascript 中实现,但我不熟悉这个选择对象。 你能帮我写一段代码,让用户的书写光标始终位于输入字符串的开头吗?
$('input[type="text"]')
.attr('maxlength','7')
.keyup(function(){
var sel = window.getSelection();
console.log(sel);
// need a code for here to make the cursor (caret) at the begining of the string
})
最佳答案
关于javascript - 我希望我的输入写在左边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11559108/