Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  151] [ 4]  / answers: 1 / hits: 28407  / 13 Years ago, sat, april 30, 2011, 12:00:00

I have a webpage where people type stuff into a text box, and it displays that text below them. That's it. There is no server side.



Let's say someone types <script src=blah>hello</script>



I want to display that as text. Not as a script, of course. How can I do that (all in javascript)?



I want to display the entire text. Don't stip the tags out.


More From » jquery

 Answers
97
$('div.whatever').text($('input.whatever').val());


That'll convert things to HTML entities, so they're displayed as they were typed, and not treated as markup.


[#92470] Thursday, April 28, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destiniemartinac

Total Points: 92
Total Questions: 106
Total Answers: 111

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;