1

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>");
4
  • If stuff is being treated as HTML, etc, use the code formatting, that's what it's there for. 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. Commented Apr 3, 2014 at 4:35
  • possible duplicate of Insert Unicode character into JavaScript Commented Apr 3, 2014 at 4:47
  • Try this: '\u{2191}' Commented Nov 4, 2017 at 22:04

3 Answers 3

5

try this string instead of an html escape character (this is a JavaScript string after all, not an html text node) \u2191'

Sign up to request clarification or add additional context in comments.

3 Comments

or maybe '\x8593'but I kind of doubt it.
Thank you - what worked was actually "\u2191" your answer got me the closest and trial and error got me the rest of the way.
@ThorSummoner No, the \x prefix is used for the so-called hexadecimal escape sequences in JavaScript, and those only accept two digits (not four). So you have to use the Unicode escape sequence which accepts four digits, as in your post.
2

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

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

1 Comment

Awesome, buddy!
0

Try using this in your html: &uparrow;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.