Lemvig Kiggeren Lemvig Kiggeren - 1 year ago 54
jQuery Question

Hide HTML code temporarily and display them later

I am trying to remove all HTML tags from a textarea-tag (TEMPORARILY), but then display the textarea value after that on the page.

<textarea><span style="color: blue">Test</p></textarea><br />

Show textarea here: <span id="show"></span>

My jQuery



That is how I show the textarea content at the moment, and that is how it is going to look in the end. Meanwhile I want to hide the HTML code from the textarea, so what is inside the textarea does not look ugly and unreadable to the common PC user. Textarea should therefore only contain "Test" (no quotations).

So basically I want to escape all HTML tags, elements, and everything related to HTML INSIDE the textarea-tag, but use it later on.


You could use regular expressions to strip out the tags, barring that you aren't trying to parse it.

var text = $('textarea').val();

Example: http://jsfiddle.net/brandonscript/ffC4q/