JS 实现TextBox光标定位
来源:互联网 发布:查询商品价格的软件 编辑:程序博客网 时间:2024/05/06 18:26
<pre name="code" class="html">//设置光标位置函数 function setCursorPosition(ctrl, pos){ <span style="white-space:pre"></span>if(ctrl.setSelectionRange){ <span style="white-space:pre"></span>ctrl.focus(); <span style="white-space:pre"></span>ctrl.setSelectionRange(pos,pos); <span style="white-space:pre"></span>} <span style="white-space:pre"></span>else if (ctrl.createTextRange) { <span style="white-space:pre"></span>var range = ctrl.createTextRange(); <span style="white-space:pre"></span>range.collapse(true); <span style="white-space:pre"></span>range.moveEnd('character', pos); <span style="white-space:pre"></span>range.moveStart('character', pos); <span style="white-space:pre"></span>range.select(); <span style="white-space:pre"></span>} }
调用方法:setCursorPosition(document.getElementById("TextBox1"),3);
ctrl:控件对象
pos:定位光标的位置
0 0
- JS 实现TextBox光标定位
- js实现文本内容光标定位,获取光标位置
- C# textbox光标定位与字符插入
- winform窗口中实现按Enter键动态将光标定位到下一个textBox控件。以登录窗口为例
- DevExpress 9.1 MemoEdit (textBox) 定位光标到文本结尾
- C# textbox中光标定位到最后一行
- C# 将光标定位到textBox控件的末尾
- 点击 TextArea 实现光标定位
- 服务器端实现光标定位事件
- js实现光标闪烁
- JS定位光标在textarea中的位置
- JS光标定位到文本框字符串末尾
- JS光标定位到文本框字符串末尾
- js将光标自动定位到文本框
- JS光标定位到文本框字符串末尾
- ionic js input光标重新定位
- 关于在使用easyui的时候,实现光标定位在easyui-combogrid和easyui-textbox输入框内(也就是获取焦点)
- 用JavaScript实现的文本框光标定位
- 有多少个PAT
- NYOJ 259 茵茵的第一课
- 学习bootstrap的过程中
- 实现滑动Tab页面
- 3D视频的播放
- JS 实现TextBox光标定位
- iOS开发 -- xib的使用
- Java PriorityQueue的使用方法
- jsp The method getServletContext() is undefined for the type in eclipse解决方法
- java 时间加工工具类
- android 屏幕方向
- svn冲突
- poj1700多种选择的贪心
- 通过LinkedHashMap缓存图片并实现LRU策略