javascript - escape HTML chracters -
i need html encode chracters input <test>
expected output <test>
.
how can this?
var encoded = htmlencode('<test>'); // returns "<test>" // ... function htmlencode(str) { var div = document.createelement('div'); var txt = document.createtextnode(str); div.appendchild(txt); return div.innerhtml; }
Comments
Post a Comment