在火狐瀏覽器中直接使用this.focus();即可實現。
在IE中,在this.focus();之后再把文本框的值賦給文本框,焦點即在最后了。很簡單喲!!
如:
復制代碼 代碼如下:
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;
}
新聞熱點
疑難解答
圖片精選