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
You want to actually use the Unicode escape sequence \u2665
in your array for replacement.
var key_stroke = { 'heart': Array('\u2665') };
The term you're looking for is "entity." There are only a few named entities in HTML, but you can specify any character by its unicode ID:
♥
will show up as: ♥
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With