'what is the character code for ♥ and how to use it?
im creating a emoticon js script and i cant seem to get the character code for ♥ to work ive tried ♥ as the character code but dosen't work any help would be help ful
my script
jQuery.fn.emotion_func = function(icon_folder) {
var emotion_locate = "emotions";
var key_stroke = { ....
"heart": Array("♥")//it dosent work
....
};
function emotion_func(html){
for(var emotion in key_stroke){
for(var i = 0; i < key_stroke[emotion].length; i++){
var key = new RegExp(key_stroke[emotion][i],"g");//replace all occurenced
html = html.replace(key,"<span style=\"background-image:url("+emotion_locate+"/"+emotion+".png); \" title="+emotion+" /></span>");
}
}
return html;
}
return this.each(function(){
$(this).html(emotion_func($(this).html()));
});
};
Any Help would be appreciated
Also note that im using html 5
Sorry but only @hwnd's answer worked for me
Solution 1:[1]
You want to actually use the Unicode escape sequence \u2665 in your array for replacement.
var key_stroke = { 'heart': Array('\u2665') };
Solution 2:[2]
try
♥
HTML character codes
http://text-symbols.com/html/entities-and-descriptions/
OR
♥
NOTE:dont forget to specify
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
and meta tag too
<meta http-equiv="Content-Type">
Solution 3:[3]
The black heart character has the unicode code 2665. In HTML unicode symbols can be output in the format prefix code suffix where prefix is always &#x and suffix is always ;. The character you want to output has the code 2665, so it can be done like this:
<p>character - ♥</p>
The output is:
character - ?
Because you are adding the character to a JavaScript array object (as literal), you need to use the unicode character representation (as @hwnd suggested) in JavaScript, by preceding the unicode character by \u (followed by the character code):
var a = Array('\u2665');
$('#panel').text(a[0]);
A reference to the unicode table containing all character codes: unicode character table.
Solution 4:[4]
Solution 5:[5]
You can see different Special and Math Symbols in HTML and JavaScript here.
Solution 6:[6]
Red Heart Symbol Hex Code
If you want to use red heart variant you have to use two unicodes:
U+2764 - stands for heavy black heart
U+FE0F - is a variation selector
To insert ?? symbol in html type it's hexcode
<p>❤️</p>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | |
| Solution 3 | |
| Solution 4 | |
| Solution 5 | Petya Kostova |
| Solution 6 | Aga |
