如何让多行文本框中,选中文本的两端分别加上[b]和[/b]
如何让多行文本框中的被选中文本的两端分别加上[b]和[/b]
------解决方案--------------------学习
------解决方案-------------------- <script>
var selecting=false;
function test(obj) {
selecting=true;
}
function mouseup(obj) {
if(selecting){
document.selection.createRange().text=[
"[b] ",
document.selection.createRange().text,
"[/b] "].join( " ");
selecting=false;
}
}
</script>
<input type= "text " onselect= "test(this) " onmouseup= "mouseup(this) " value= "select Me! "/>
------解决方案-------------------- <script>
var str= "3284234 ";
var re=/([\s\S]*)/;
alert(str.replace(re, "[b]$1[/b] "))
</script>