【发布时间】:2012-07-19 10:43:16
【问题描述】:
我知道这可以通过使用 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 html window getselection