I am trying to assign the comment text to an element, which is supposed to contain some html. So I am trying to encode the comment text before displaying it on the page after submitting. I have tried the following procedure but its not encoding the html. I want the html to be converted to literals.
                var span=document.createElement("span");
                span.innerText=commenttext;
                console.log(span.innerText);
Edit
1) commenttext is a variable. 
2) by literals I mean encoded html... <.. etc
 
     
     
     
    