2011-10-27 98 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