jQuery Escaping HTML from a Textarea -
I want to hide the names of the tags from the HTML tags, text from a textarea and the result In the second textarea is such that:
& lt; Mytag & gt; becomes
& amp; Lt; Mytag & gt; I am using .html () and .text () and going forward is fine. My problem is working with the textarea element, which works a bit differently.
This works fine if I first enter text in a lesson:
var htmlStr = $ ('# textareaInput'). Val (); // do not like it. Html () .text ()? . $ ('# Dummy') text (htmlStr); // An object that supports text. HTML () $ ('# textareaOutput') Val ($ ('# dummy') .HTML ()); But I want to do something simpler like this:
var htmlStr = $ ('# textareaInput'). Val (); . $ ('# TextareaOutput') Val ($ (htmlStr) .html ()); I think my problem is that I do not understand that to manipulate the objects of jQuery, like strings, without manipulating the dome elements - because now I am using a div Because in the .html () method. Any help would be great!
Thank you.
Try
var htmlStr = $ ('# textareaInput' ). Val (); $ ('# TextareaOutput') Values ($ ('& Lt; div / & gt;') Text (htmlStr) .html ());
Comments
Post a Comment