我正在创建一个表情符号的js脚本,但似乎无法获取♥
的字符代码。我尝试使用♥
作为字符代码,但不起作用。求助!
我的脚本:
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()));
});
};
希望得到任何帮助。
另外请注意,我正在使用HTML 5。
抱歉,但只有@hwnd的答案对我有用。
\u2665
。 - hwnd