jQuery在Div中的字符处插入文本

jQuery在Div中的字符处插入文本,jquery,text,html,Jquery,Text,Html,我有一个divlike <div class="mycooldiv"> bunch of text is in here and for example some # and some other cool # </div> 这里有一堆文字,例如一些#和一些其他很酷的文字# 如何在#处插入文本?尝试使用正则表达式将#替换为要插入的文本 var $div = $('.mycooldiv'); $div.text($div.text().replace(/#/,

我有一个
div
like

<div class="mycooldiv">
    bunch of text is in here and for example some # and some other cool #
</div>

这里有一堆文字,例如一些#和一些其他很酷的文字#

如何在
#
处插入文本?

尝试使用正则表达式将#替换为要插入的文本

var $div = $('.mycooldiv');
$div.text($div.text().replace(/#/, 'Text to insert here');