随身笔记
随身笔记

jquery 光标定位

js光标获取位置

 $.fn.selectRange = function(start, end) { 
    return this.each(function() { 
      if (this.setSelectionRange) { 
         this.focus(); 
         this.setSelectionRange(start, end); 
      } else if (this.createTextRange) { 
         var range = this.createTextRange(); 
         range.collapse(true); 
         range.moveEnd('character', end); 
         range.moveStart('character', start); 
         range.select(); 
       } 
    }); 
 }; 

 $('#shownum').selectRange(3,5);  //开始位置,结束位置

随身笔记

jquery 光标定位
js光标获取位置 $.fn.selectRange = function(start, end) { return this.each(function() { if (this.setSelectionRange) { this.focus(); this.…
扫描二维码继续阅读
2015-12-11