如何使用jquery和focus函數(shù)把光標(biāo)定位到input中文字的最后?
在做ajax無刷新修改時,需要在編輯的時候,將光標(biāo)定位到input文本框中文字的最后面。這里介紹如何使用jquery和focus函數(shù)把光標(biāo)定位到input中文字的最后的方法?
代碼如下:
<script src="jquery.js"></script>
<script>
$(function(){
str = $("#aaa").val();
$("#aaa").val("").focus().val(str);
});
</script>
<input type="text" value="123456789" id="aaa" />
代碼如下:
<script src="jquery.js"></script>
<script>
$(function(){
str = $("#aaa").val();
$("#aaa").val("").focus().val(str);
});
</script>
<input type="text" value="123456789" id="aaa" />
中國· 上海

添加微信咨詢
關(guān)鍵詞
辦公室:上海市浦東新區(qū)郭守敬路351號
CopyRight?2009-2019 上海谷谷網(wǎng)絡(luò)科技有限公司 All Rights Reserved. 滬ICP備11022482號-8
- top
- 在線咨詢
-
添加微信咨詢