Here is my string.
<div id='content'>here is my text {{ and some more }}</div>
I want to replace all {{ with < pre > tags and }} with < /pre > tags.
so the string would output like this.
<div id='content'>here is my text <pre> and some more </pre></div>
i need to do this using jquery. i have got so far.
var textarea=$('#content').text();
$(".addesc1").text(textarea).html().replace(/{{/g, "<pre>");
whats the best function to use.
You could do some thing simple like:
as illustrated here: http://jsfiddle.net/MarkSchultheiss/psSwE/
This says "Take my jQuery object "textarea" and replace the "{{" and then take that result set and replace the "}}".
I WOULD suggest changing the name of your variable however as "var textarea" just might confuse future developers (make them pause to think is not good).
EDIT: Note that the use of the jQuery "chaining" is one of the cool things about it.