javascript - How to display heart symbols unicode to webpage?
问题描述
I have at table in which there is list of symbols with their details and on click of Get Code
button i am passing values to modal to show hear symbol details to modal.
Here is my table one example list code :
<tr>
<td style="font-size: 30px;">❤</td>
<td>Classic Heart Emoji</td>
<td>
<button type="button" class="code-btn" data-toggle="modal" data-target="#exampleModal"
onClick="sendvalue('Classic Heart Emoji','#x2764','#10084','U+2764','Heavy black Heart','Dingbats','❤');">Get
Code</button></td>
</tr>
Here is my bootstrap modal code :
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Symbol Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span class="white" aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="row ml-0 mr-0">
<div class="col-md-4 col-12">
<div class="modal-emoji" id="mysymbol" style="font-size:75px">
</div>
</div>
<div class="col-md-8 col-12">
<h3 class="site-text grey" id="title">
<br>
</h3>
<div class="custom-text" id="symbol">
</div>
<p class="site-text grey" id="code">
<br>
</p>
<p class="site-text grey" id="unicode">
<br>
</p>
<p class="site-text grey" id="unicodename">
<br>
</p>
<p class="site-text grey" id="unicodeblock">
<br>
</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="code-btn" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Here is my js function :
function sendvalue(title, html1, html2, unicode, unicodename, unicodeblock, symbol) {
console.log(html1, html2,unicode)
document.getElementById("mysymbol").innerHTML = symbol;
document.getElementById("title").innerHTML = title;
document.getElementById("symbol").innerHTML = "Symbol / Emoji: " + symbol;
document.getElementById("code").innerHTML = '&'+html1+"; OR "+'&'+html2+";";
document.getElementById("unicode").innerHTML = "<b>Unicode : <b>" + unicode;
document.getElementById("unicodename").innerHTML = "<b>Unicode Name : </b> " + unicodename;
document.getElementById("unicodeblock").innerHTML = "<b>Unicode Block : </b> " + unicodeblock;
}
The problem is when in modal unicode is converting into symbol but i want to show that symbol html quivalent code exactly as i am passing this code #10084
as string in function and then in function appending &
with it inside function to show on screen like ❤
. But it is converting this code to symbol. How can i fix it?
解决方案
I believe your answer should be at the following url: http://www.javascripter.net/faq/mathsymbols.htm
It appears you have to use the code ♥.
Is this what you were looking for?
推荐阅读
- kubernetes - 为什么无法在 kubernetes 集群中使用 $(service name).$(namespace).svc.cluster.local ping statefulset
- mysql - 通过在 MYSQL 中发送电子邮件和代码来恢复忘记的密码
- github - 使用 http 代理连接 github 失败
- python - Altair:如何更改分组条形图中列标题的字体大小?
- linux - linux elf .bss 部分内存成本
- python-3.x - Azure Functions Http 在收到 pdf 文件时触发,然后使用 Form Recognizer [python] 分析表单
- python - 如何在没有理解的情况下填写字典
- spring-boot - 在 thymeleaf 中设置 th:field 属性正在替换 name 属性
- wpf - 当我对单元格(tableview)进行任何操作并保存某些内容时,图像应该在使用 wpf c# mvvm 的单击单元格中带有相同的数据
- javascript - 在 Typescript 中编写强类型对象反规范化器