Js set the focus position in the text box in the last sample code of of simple utility

  • 2020-03-30 02:13:55
  • OfStack

Use this.focus() directly in firefox; Can be achieved.

In IE, in this.focus(); Then you assign the value of the text box to the text box, and the focus is at the end. It's easy!!

Such as:


var tar=document.getElementByIdx_x("name");
if(tar.attachEvent){
tar.attachEvent('onmouseover',focus(tar),false);
}else{
tar.addEventListener('mouseover',focus(tar),false);
}
function focus(tar){
    tar.focus();
    tar.value=tar.value;
}


Related articles: