简体   繁体   中英

can't get unicode character to display properly - Javascript and HTML

I'd like to put a unicode up arrow in an html input button that is being generated in Javascript.

These are the codes for the up arrow from unicode-table.com:
Unicode number: U+2191
HTML-code: & #8593; (space between the & and # so you can see the code and not the arrow)

I do have
<charset="utf-8" /> in my head tag in the html file.

I've tried every variation of those two codes I can think of within the <> below and all I get in the browser is the text of the codes I've tried.

Here's the line of code:

upButton.setAttribute("value", "<up arrow code here>");

尝试使用此字符串而不是html转义字符(毕竟这是JavaScript字符串,而不是html文本节点) \↑'

To escape any symbol in JavaScript , use this tool: http://mothereff.in/js-escapes#1%E2%86%91 For your example, '↑' becomes '\↑' .

To escape any symbol in HTML, use this tool: http://mothereff.in/html-entities#%E2%86%91 For your example, becomes &#x2191; or &uarr; .

尝试在html中使用它: &uparrow;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM