javascript - escape HTML chracters -


i need html encode chracters input <test> expected output &lt;test&gt;.

how can this?

var encoded = htmlencode('<test>');    // returns "&lt;test&gt;"  // ...  function htmlencode(str) {     var div = document.createelement('div');     var txt = document.createtextnode(str);     div.appendchild(txt);     return div.innerhtml; } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -