1个回答
展开全部
$.fn.extend({
05 position:function( value ){
06 var elem = this[0];
07 if (elem&&(elem.tagName=="TEXTAREA"||elem.type.toLowerCase()=="text")) {
08 if($.browser.msie){
09 var rng;
10 if(elem.tagName == "TEXTAREA"){
11 rng = event.srcElement.createTextRange();
12 rng.moveToPoint(event.x,event.y);
13 }else{
14 rng = document.selection.createRange();
15 }
16 if( value === undefined ){
17 rng.moveStart("character",-event.srcElement.value.length);
18 return rng.text.length;
19 }else if(typeof value === "number" ){
20 var index=this.position();
21 index>value?( rng.moveEnd("character",value-index)):(rng.moveStart("character",value-index))
22 rng.select();
23 }
24 }else{
25 if( value === undefined ){
26 return elem.selectionStart;
27 }else if(typeof value === "number" ){
28 elem.selectionEnd = value;
29 elem.selectionStart = value;
30 }
31 }
32 }else{
33 if( value === undefined )
34 return undefined;
35 }
36 }
37 })
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询