° 添加 .placeholder 时不显示在占位符中
° not showing in placeholder when added with .placeholder
我正在尝试使用 .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 实体代码(如 °
):
inp.placeholder = "Enter \u00B0C";
您可以使用 this web tool 找到给定 HTML 实体的 javascript 字符转义。
我正在尝试使用 .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 实体代码(如 °
):
inp.placeholder = "Enter \u00B0C";
您可以使用 this web tool 找到给定 HTML 实体的 javascript 字符转义。