将光标放在文本输入值的末尾 [英] put cursor at end of text input's value
本文介绍了将光标放在文本输入值的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以,目前我有一个文本输入字段,其值也是自动聚焦的。
So, currently I have a text-input-field with a value that is also autofocused.
在页面加载时,值被选中/突出显示。是否有一种方法,我可以把光标放在值文本的结尾,而不是在javascript或CSS中突出显示?
On page load, the value is selected / highlighted. Is there a way I can put the cursor at the end of the value text instead of highlighting it in javascript or CSS?
这里是一个js fiddle哪里自动聚焦文本的值已突出显示: http://jsfiddle.net/TaGL5/
Here is a js fiddle where the autofocused text's value is highlighted: http://jsfiddle.net/TaGL5/
此处是HTML代码:< input type =textvalue =value textautofocus />
Here is the HTML code: <input type="text" value="value text" autofocus />
推荐答案
这适用于我
<input type="text" autofocus value="value text" onfocus="this.value = this.value;"/>
这篇关于将光标放在文本输入值的末尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文