Select the tab text

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
<title>无标题文档</title>
</head>

<body>
<p>我的</p>
<textarea id="o">我的g我的g我的g</textarea>
<input type="button" value="aaaa" onclick="setSelectText(document.getElementById('o'),index,index+spanText.length)" />
<script>

was span text = $ ( 'p'). text ();
was textarea_text = $ ( '# o'). choices ();
was textarea_text.indexOf Index = (span text);

function setSelectText(el,start,end){
if(el.createTextRange){
var Range=el.createTextRange();
Range.collapse();
Range.moveEnd('character',end);
Range.moveStart('character',start);
Range.select();
}
if(el.setSelectionRange){
el.focus();
el.setSelectionRange(start,end); //设光标
}
}
</script>
</body>
</html>

Guess you like

Origin www.cnblogs.com/lch1990/p/11290526.html
Tab
Tab
Tab
Tab