如何选中textarea中指定文字 选中 textarea中指定文字<textarea cols="40" rows="10" id="target"><div>php<div>qqq</div></textarea>怎么让 <div>php</div>是选中状态注:textarea 中可以看到 div标记 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>function foo(){ var textbox= document.getElementById('target'); selectText(textbox,0,14);}function selectText(textbox,startIndex,stopIndex){ if(textbox.setSelectionRange){ textbox.setSelectionRange(startIndex,stopIndex); }else if(textbox.createTextRange){ var range=textbox.createTextRange(); range.collapse(true); range.moveStart('character',startIndex); range.moveEnd('character',stopIndex-startIndex); range.select(); } textbox.focus();}</script><textarea cols="40" rows="10" id="target"><div>php</div><div>qqq</div></textarea><input type="button" onclick="foo()" value="Click"> javascript 两组radio 如何让其在每组各有其中一个值选中时相乘得到结果 任意一组没有任何选中时报错 ext_js 小问题 再次求教hao123、265、2345断网能访问的问题! 小白勿入。非常高深强悍的静态网站技术。。。 去除call的作用 Ext用表单提交下拉框的问题 求助: 关于伸缩屏广告js代码的问题 求汉字正则表达式的写法 提一个小问题,50分相送 请问有没有办法改变<body>里面的属性值? 教训,惨痛的教训!!!!!!!!!!!!!!!!!!!!!!!!!!! 帮我改进一下这个jquery代码 被这个最小的问题搞晕了
function foo(){
var textbox= document.getElementById('target');
selectText(textbox,0,14);
}
function selectText(textbox,startIndex,stopIndex){
if(textbox.setSelectionRange){
textbox.setSelectionRange(startIndex,stopIndex);
}else if(textbox.createTextRange){
var range=textbox.createTextRange();
range.collapse(true);
range.moveStart('character',startIndex);
range.moveEnd('character',stopIndex-startIndex);
range.select();
}
textbox.focus();
}
</script>
<textarea cols="40" rows="10" id="target">
<div>php</div>
<div>qqq</div>
</textarea>
<input type="button" onclick="foo()" value="Click">