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
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: ♥