这是我的字符串。jquery查找并替换
<div id='content'>here is my text {{ and some more }}</div>
我想</pre>标记替换所有{{与< pre>标记和}}。
所以字符串会像这样输出。
<div id='content'>here is my text <pre> and some more </pre></div>
我需要使用jquery来做到这一点。我到目前为止。
var textarea=$('#content').text();
$(".addesc1").text(textarea).html().replace(/{{/g, "<pre>");
什么是最好的功能使用。
同意正则表达式,为什么拉如果你不必。 – 2011-06-01 12:57:05
这是对一般良好做法的奖励。只要答案也在帖子中,我没有看到任何问题。 – deadalnix 2011-06-01 13:12:03