I have a script that writes a string to <textarea>
. The string may contain HTML entities (like &
). When the string is written to the <textarea>
, the HTML entities are decoded.
var str = 'foo & bar';
form.text.value = str;
What happens:
Textarea: foo & bar
What I want:
Textarea: foo & bar
How can I accomplish this?
Edit How can I accomplish this in javascript, not PHP?