Javascript &;度;添加.placeholder时未显示在占位符中

Javascript &;度;添加.placeholder时未显示在占位符中,javascript,input,placeholder,Javascript,Input,Placeholder,我正在尝试使用.placeholder更改输入上的占位符文本。我正在使用 ° 得到一个° cel.onclick = function() { cel.className += "active"; reset(); faren.classList.remove("active"); inp.placeholder = "Enter °C"; }; faren.onclick = function() { faren.cl

我正在尝试使用.placeholder更改输入上的占位符文本。我正在使用

°
得到一个°

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";
};

这将输出
°代替符号,有人能解释如何更改它吗。谢谢。

尝试使用javascript字符转义码(如
\u00B0
)代替HTML实体码(如
°;
):


您可以使用do查找给定HTML实体的javascript字符转义。

是否有任何东西阻止您将实际的°符号粘贴到占位符字符串中?您的意思是它输出°;?是的,很抱歉忘记将其添加为codeinp.placeholder='Enter'+String.fromCharCode(176)+'C';实际上没有@Zac,我觉得有点愚蠢,因为我刚刚不得不用谷歌搜索如何放置符号。谢谢
inp.placeholder = "Enter \u00B0C";