I'm trying to use .placeholder to change the placeholder text on an input. I'm using
°
to get a °
cel.onclick = function() {
cel.className += "active";
reset();
faren.classList.remove("active");
inp.placeholder = "Enter °C";
};
faren.onclick = function() {
faren.className += "active";
reset();
cel.classList.remove("active");
inp.placeholder = "Enter °F";
};
This outputs °
instead of the symbol, can anyone explain how to change this. Thanks.
Try using the javascript character escape code (like \u00B0
) for the symbol instead of the HTML entity code (like °
):
inp.placeholder = "Enter \u00B0C";
You can use this web tool to do find the javascript character escape given an HTML entity.