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:
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>");
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.:
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>");
Share
Improve this question
asked Apr 3, 2014 at 4:26
lwaldenlwalden
8037 silver badges11 bronze badges
4
- If stuff is being treated as HTML, etc, use the code formatting, that's what it's there for. – alex Commented Apr 3, 2014 at 4:28
- not sure what you mean by that @Alex. It seems if I create the button in the html file it works fine, but create th button in Javascript and it will not. For my purposes I need to create it in Javascript, however. – lwalden Commented Apr 3, 2014 at 4:35
- possible duplicate of Insert Unicode character into JavaScript – Jukka K. Korpela Commented Apr 3, 2014 at 4:47
-
Try this:
'\u{2191}'
– Piotr Kowalski Commented Nov 4, 2017 at 22:04
3 Answers
Reset to default 5try this string instead of an html escape character (this is a JavaScript string after all, not an html text node) \u2191'
To escape any symbol in JavaScript, use this tool: http://mothereff.in/js-escapes#1%E2%86%91 For your example, '↑'
bees '\u2191'
.
To escape any symbol in HTML, use this tool: http://mothereff.in/html-entities#%E2%86%91 For your example, ↑
bees ↑
or ↑
.
Try using this in your html: ↑