如何在Google Chrome输入文字末尾设置光标位置 [英] How to set cursor position at the end of input text in Google Chrome
问题描述
我试图在具有焦点功能的文本字段中设置光标。我做了一些研究,但所提供的解决方案似乎都不适用于Google Chrome。在Internet Explorer和Firefox中,这个解决方案工作正常:
js:
var SearchInput = $('#Search');
var strLength = SearchInput.val()。length;
SearchInput.focus();
SearchInput [0] .setSelectionRange(strLength,strLength);
});
HTML:
< input type =textid =Searchvalue =Hello World/>
以下是我的 jsfiddle 。
有什么方法可以在谷歌浏览器中使用它?
$ b