これが私が得たものです-:
<div contenteditable="true">Hey man @tt</div>
<a></a>
これで、入力されたときにラップアラウンドしたいと思い@
ます。
たとえば、@
が押された場合、html は次のようになります。
<div contenteditable="true">Hey man <a>@</a>tt</div>
使用してreplace()
ください。
これを試して
var output= $('div').html().replace('@','<a>@</a>');
$('div').html(output);
$('input').keypress(function(e){
if ((e.shiftKey == true) && (e.charCode == 64))
{
$(this).html().replace('@','<a>@</a>');
}
});