I was wondering if there is a way I could apply htmlentities()
to var x
so that if I put <p>hello</p> into the text area
and press the button it would display <p>hello</p> instead of hello using the below code.
Thanks in advance
function myFunction1() {
var x = document.getElementById("myText1").value;
document.getElementById("demo1").innerHTML = x;
}
<textarea name="myText" id="myText1" type="text"></textarea><button onclick="myFunction1()">thing</button><p><span id="demo1"></span></p>