我找到了大量的好的,跨浏览器的答案,如何 准备好了插入符号的位置在 contentEditable
元素,但没有一个如何 走开插入符号的位置摆在首位。
我想要做的是知道在 keyup
的 div 中插入符号的位置。因此,当用户输入文本时,我可以在任何时候知道 contentEditable
元素中插入符号的位置。
<div id="contentBox" contentEditable="true"></div>
$('#contentbox').keyup(function() {
// ... ?
});