当前位置: 代码迷 >> ASP.NET >> javascript怎么判断光标在文本框中的位置
  详细解决方案

javascript怎么判断光标在文本框中的位置

热度:4045   发布时间:2013-02-25 00:00:00.0
javascript如何判断光标在文本框中的位置?
也就是判断光标在第几个字符后

------解决方案--------------------------------------------------------
板凳~~~~~~~~~~~~~~
------解决方案--------------------------------------------------------
顶一下
------解决方案--------------------------------------------------------
写个简单的 <input type= "text " id= "txt1 " onkeydown= "javascript:return ShowPos(); "/> <div id= "div1 "> </div> <script type= "text/javascript "> <!-- function ShowPos() { var s=document.selection.createRange(); s.setEndPoint( "StartToStart ",document.getElementById( "txt1 ").createTextRange()) var pos = s.text.length; document.getElementById( "div1 ").innerHTML = pos; }//--> </script>
  相关解决方案