2011-10-27 96 views
0

字符jQuery的插入文本我在#一个div在股利

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

我怎样才能插入文本 - 在#可以在任何位置?

回答

2

尝试使用正则表达式替换带有要插入文本的#号。

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

ah right cool - good ole'replace' – Andy