-1

我正在使用此答案中的代码:

$("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
});

注释指出,这假定光标位于文本框的末尾。我尝试搜索如何获取光标位置以解决此问题,但不知道该怎么做?

如何找到光标的当前位置?

4

1 回答 1

0

我对此进行了更多搜索,发现我们可以使用 JQuery JCaret 插件来完成此操作。有关插件及其用法的更多详细信息,请参阅以下网页:http: //archive.plugins.jquery.com/project/jCaret

于 2013-07-04T08:53:59.273 回答