首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

将光标定位在text,textarea最后的步骤

2012-10-11 
将光标定位在text,textarea最后的方法var setpos function(o){if (o.setSelectionRange) {setTimeout(fu

将光标定位在text,textarea最后的方法

var setpos = function(o){   if (o.setSelectionRange) {       setTimeout(function(){      o.setSelectionRange(o.value.length, o.value.length);        o.focus()} ,0)   }else if (o.createTextRange) {    var textrange=o.createTextRange();    textrange.moveStart("character",o.value.length);    textrange.moveEnd("character",0);    textrange.select();  }  };

热点排行