当前位置:K88软件开发文章中心编程语言AjaxAjax01 → 文章内容

如何使用jquery和focus函数把光标定位到input中文字的最后?

减小字体 增大字体 作者:佚名     来源:asp编程网  发布时间:2018-12-30 9:22:37

在做ajax无刷新修改时,需要在编辑的时候,将光标定位到input文本框中文字的最后面。这里介绍如何使用jquery和focus函数把光标定位到input中文字的最后的方法?
代码如下:
<
script src="jquery.js">
<
/script>

<
script>

$(function()
{
str = $("
#aaa").val()

$("
#aaa").val("").focus().val(str)

})

<
/script>

<
input type="text" value="123456789" id="aaa" />


如何使用jquery和focus函数把光标定位到input中文字的最后?