jQuery Escaping HTML from a Textarea
I want to escape HTML tags to entity names, taking text from a textarea and putting the result in a second textarea such that: <mytag> becomes <mytag> I'm using .html() and .text() going back and forth OK. My problem is dealing with the textarea element, which acts a little different. It works fine if I first place the text into a div: var htmlStr = $('#textareaInput').val(); //doesn't like .html() .text() ? $('#dummy').text(htmlStr); // an object to hold the text that supports .html() $('#textareaOutput').val($('#dummy').html()); But I want to do something more straightforward like this: var