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

jquery 选中input点前面的文本

时间:2015-12-19 11:12:08      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

 1 <!DOCTYPE HTML>
 2 <html>
 3 <head>
 4 <meta charset=UTF-8 />
 5 <title>Foucus</title>
 6 <script type=‘text/javascript‘ src=‘http://ajax.useso.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=3.4.2‘></script>
 7 <script type="text/javascript">
 8    
 9     $(function(){
10         $(#t2).on(mouseup,function(){
11             var obj        = $(this);
12             var val        = obj.val();
13             var index     = - val.replace(/.*(\.[^\.]+)$/, $1).length;
14             obj.get(0).selectionStart=0;
15             obj.get(0).selectionEnd=val.length + index;
16         })
17     });
18     
19 </script>
20 
21 </head>
22 <body>
23     <h2>mytest</h2>File Name:<input type="text" id="t2" value="abcdefg.doc" />
24 </body>
25 </html>

 

jquery 选中input点前面的文本

标签:

原文地址:http://www.cnblogs.com/fsong/p/5058716.html

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