setFocus=function(id){
var t=$( "#" id).val();
$("#" id).val("").focus().val(t);
}
Put The focus cursor moves to the end of the id text.
After jquery gets focus, the cursor is behind the string. When input gets focus, it automatically moves the cursor to the end of the text content. jQuery uses focus() to focus the text input box and the focus is on the rightmost side of the text. Method
//The cursor is after the string after getting focus
//The principle is to copy and paste yourself again after getting the focus
var t=$("#" id).val();
$("#" id).val(" ").focus().val(t);