gpt4 book ai didi

javascript - ♥的字符代码是什么以及如何使用它?

转载 作者:行者123 更新时间:2023-12-03 16:29:17 28 4
gpt4 key购买 nike

我正在创建一个表情符号 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 的回答对我有用

最佳答案

您想实际使用 Unicode escape sequence \u2665在您的阵列中进行更换。

var key_stroke = { 'heart': Array('\u2665') };

关于javascript - ♥的字符代码是什么以及如何使用它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23445212/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com