【发布时间】:2017-09-17 01:18:29
【问题描述】:
我想使用 javascript 将某些实体转换为其实体编号。有这样做的功能吗?我可以为某些特定实体做这件事吗?
示例:
我想在控制台中输出 € 实体作为其 html 实体编号:€。
这里是JSFiddle
html
<div>I want to retreive the euro character from the button, get the html code that belongs to it and output it in the console.log. So the console.log should state: "Euro-symbol: (html code here)!!!"</div>
<button id="alt-char">Euro-symbol: €!!!</button>
javascript
var a = document.getElementById('alt-char').innerHTML;
console.log(a);
【问题讨论】:
-
您能对这个问题多加一点解释吗?目前有点难以理解你想要什么。
-
@evolutionxbox 我在问题中添加了一个示例。希望它可以清除一点。
-
我设法使用 charCode 和来自 Ines Tlili 的链接的一些灵感来整理一个解决方案:jsfiddle.net/w5ocjwv8/2 谢谢大家的帮助 :)。
标签: javascript html