Marchhill Marchhill - 27 days ago 9
HTML Question

Emoji buttons html

I am making a html website and I am trying to put unicode (utf-8) emojis on it. When I try to use unicode emojis on a button it works, but I need to use the jquery attr method to set the button value, and then it just comes up as unicode letters -- how can I fix this?

$("#example").attr("value", "😁");


(Example is a button)

<input type="button" name="example" id="example" value="example" class="btn btn-primary">

Answer

You need to render it as HTML, in which case use:

$("#example").html("&#x1F601;");

jsFiddle example