码迷,mamicode.com
首页 > Web开发 > 详细

利用js在文本框末尾获得焦点

时间:2014-08-30 00:04:18      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:js

function moveEnd(obj) {
	obj.focus();
	var len = obj.value.length;
	if (document.selection) {
		var sel = obj.createTextRange();
		sel.moveStart(‘character‘, len);
		sel.collapse();
		sel.select();bubuko.com,布布扣
	} else if (typeof obj.selectionStart == ‘number‘
			&& typeof obj.selectionEnd == ‘number‘) {
		obj.selectionStart = obj.selectionEnd = len;
	}
}

利用js在文本框末尾获得焦点

标签:js

原文地址:http://blog.csdn.net/frightingforambition/article/details/38933399

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!