The following article gives you a brief introduction of jquery implementation Click Input to move the cursor to the last or specified location example, I hope to help you, you need to know that facing a Virgo demand, focus () is far from enough, for example, "When I click the cursor in the end, So I don't have to move the cursor to the end to add something. "Oh, let me hit the wall first."
We need to extend jquery with the following code:
//The cursor is placed at the end of the $ ("#文本框ID"). Textfocus (); the cursor is placed after the second character $ ("#文本框ID"). Textfocus (2); (function($) {$.fn.textfocus=function(v) {varRange,len,v=v===undefined?0:p Arseint (v); This. each (function(){ if($.browser.msie) {range= This. createTextRange (); V===0?range.collapse (false): Range.move ("character", V); Range.Select (); }Else{len= This. Value.length; V===0? This. Setselectionrange (Len,len): This. Setselectionrange (V,V); } This. focus (); }); return This; }}) (JQuery);
Another simple method, the code is as follows:
var t=$ ("#" +ID). val (); $ ("#"+id). Val (""). Focus (). val (t);
jquery implementation Click Input to move the cursor to the last or specified position