Pekka Pekka - 4 months ago 29x
jQuery Question

Using jQuery to add a ✔ tick mark in span

From this question I learned that the check mark is the code

✔ (0x2714 [HTML decimal: ✔])
. I know that you add text to a span using jQuery by doing
. I want to add the check mark to the span.

I did it like

$('#spanid').text(✔); //This errors on the `&`
$('#spanid').text(#10004); //This results in `Unexpected token ILLEGAL

What is the correct way of doing this?


Use .html(). Also, enclose the value in quotes.


.text() will convert the input to text string. .html() converts to HTML string/content and the character encoded can be seen.

Fiddle Demo

or if you already have the character , .text() would work;