我正在使用此答案中的代码:
$("input[x]").keypress(function (e) {
var c = String.fromCharCode(e.which);
//process the single character or
var textValue = $("input[x]").val();
var fulltext = textValue + c;
//process the full text
});
注释指出,这假定光标位于文本框的末尾。我尝试搜索如何获取光标位置以解决此问题,但不知道该怎么做?
如何找到光标的当前位置?