最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
将鼠标焦点定位到文本框最后的代码分享
时间:2022-06-25 17:22:12 编辑:袖梨 来源:一聚教程网
经测试,兼容IE8
| 代码如下 | 复制代码 |
//设置焦点相关---begin //用法:$("#txtInput").val("你好").focusEnd(); $.fn.setCursorPosition =function(position) { if(this.lengh == 0)returnthis; return$(this).setSelection(position, position); } $.fn.setSelection =function(selectionStart, selectionEnd) { if(this.lengh == 0)returnthis; input =this[0]; if(input.createTextRange) { varrange = input.createTextRange(); range.collapse(true); range.moveEnd('character', selectionEnd); range.moveStart('character', selectionStart); range.select(); }elseif(input.setSelectionRange) { input.focus(); input.setSelectionRange(selectionStart, selectionEnd); } returnthis; } $.fn.focusEnd =function() { if(this.val() != undefined) { this.setCursorPosition(this.val().length); } } //设置焦点相关---end | |
相关文章
- 学习通官网登录入口-学习通在线平台直达链接 02-04
- 非麻瓜漫画官方网页入口下载安装最新版本-非麻瓜漫画官方正版入口安卓苹果通用 02-04
- ao3最新链接入口-ao3官网直达入口 02-04
- 差差漫画在线阅读入口-差差漫画免费登录入口 02-04
- 差差漫画安卓完整版下载-差差漫画2026最新版v1.0下载 02-04
- 币安提币时网络错误怎么办?能不能找回? 02-04