Ver original$("#botondelevento").click(function(){ selectedText = document.getSelection(); $("#texto").replaceSelection("[CODIGO]"+selectedText+"[/CODIGO]"); });