在线演示:demo
本着学习的态度,本项目所有的材料来源于网络。如果有侵权,请联系删除。
大佬eshengsky的jQuery_emoji项目,大家可以去大佬的项目看看,参考大佬的项目而写的。
本项目的功能,可以自主选择表情,包括QQ表情,贴吧表情,经典的emoji表情,根据需要选择
本项目还可以解析表情字符,替换成图片,在div中展示
下载:emoji_jQuery.min.js,然后在jQuery后引入使用。
- HTML代码
<div id="test"></div>
<div id="div-emoji"><p><input id="input" type="text"><input id="btn" type="button" value="emojiBtn"></p></div>
-
设置表情
参数说明:emojiInput:输入框,必须要有;emojiBtn:显示表情按钮,必须要有;position:位于emojiBtn什么位置,默认在右下方 length:每行要展示的表情数;emojis:需要的表情组;
$.Lemoji({
emojiInput: '#input',
emojiBtn: '#btn',
position: 'LEFTBOTTOM',
length: 8,
emojis: {
qq: {path: 'static/images/qq/', code: ':', name: 'QQ表情'},
tieba: {path: 'static/images/tieba', code: ';', name: "贴吧表情"},
emoji: {path: 'static/images/emoji', code: ',', name: 'Emoji表情'}
}
});
-
解析表情
参数说明:content:需要解析的内容;emojis:要与设置表情的一致,不然无法解析成功
$('#btn').click(function () {
var content = $('#input').val();
content = $.emojiParse({
content: content,
emojis: [{type: 'qq', path: 'static/images/qq/', code: ':'}, {
path: 'static/images/tieba/',
code: ';',
type: 'tieba'
}, {path: 'static/images/emoji/', code: ',', type: 'emoji'}]
});
$('#test').html(content);
});
1 下载该项目
git clone https://github.com/li914/emoji_jQuery.git
cd emoji_jQuery
2 添加依赖
npm install
3 运行项目
npm run server