Display formatted raw html with jquery

Haveartette

New Member
I have a place where I am trying to show code in a text area. I have dumbed down the example but basically user can input some fields, click a button, and the code snippet displays in a text area below for them to edit if they want and then copy.I finally got it working to display the actual code snippet. But now I can't seem to find a way to format it so that it is indented and looks nice.\[code\]var mySnippet ="<div id=\"myOuterDiv\">" + "<div id=\"myInnerDiv\">" + "</div>" + "</div>";$('#mySnippetArea').text(eventSnippet);\[/code\]Which displays in my text area like so.\[code\]<div id="myOuterDiv"><div id="myInnerDiv"></div></div>\[/code\]Where as I would like to see it as:\[code\] <div id="myOuterDiv"> <div id="myInnerDiv"> </div> </div>\[/code\]I'd really like to avoid any 3rd party plugins as its for work an a pain to get approval. It's just 4 small snippets I need to format.
 
Back
Top