I am trying to show up some HTML Special Chars like ☚ and I want that, when click it, it will display it’s code on a textarea.
I am trying something like this:
insertHTMLCode = function(code){
var currentText = document.getElementById("textBox");
var codeWithPadding = " " + code + " ";
currentText.value += codeWithPadding;
currentText.focus();
}
However it always gets the symbol itself on the textarea instead the code (like ►)?
You can use
charCodeAtto get the numeric value of a character, and from there, you can generate the entity code: