现在的位置: 首页 > web前端 > 正文

jQuery-emoji表情插件的使用

2020年02月12日 web前端 ⁄ 共 2458字 ⁄ 字号 评论关闭

功能 features

支持给textarea或可编辑p加上表情功能,自动识别元素类型。 Support for adding emoji into textarea or editable p, automatic identification of element types.如果是textarea,则选择表情后插入表情代码,如果是可编辑p,则直接插入表情图片。 If it is textarea element,will insert code string of emoji, else, will insert emoji picture directly.支持自定义表情代码的格式。 Support for specifying the code format of emoji.支持将表情代码转换为表情图片。 Support for converting the code string of emoji into emoji picture.支持多组表情并提供tab切换。 Support for multiple groups of emoji and tabs to toggle.示例已带有百度贴吧和qq高清2套表情。 The demo has been with 2 sets of emojis:Baidu tieba emoji & QQ HD emoji.同一页面支持多个表情实例。 Support for multiple instances in one page.

使用示例

$("#editor").emoji({ icons: [{ name: "QQ表情", path: "img/qq/", maxNum: 91, excludeNums: [41, 45, 54], file: ".gif", placeholder: "#qq_{alias}#" }]});

开始使用

安装 install

$ bower install jquery-emoji

或在http://www.jq22.com/jquery-info6363此页面下载

引入文件 首先在页面上引用css文件和js文件,css文件一般在中添加,js文件一般在之前添加。注意要先引用jquery和jquery.mCustomScrollbar,再引用该js。 Firstly reference the css and js file of this plugin, the best location of the css reference is in , and the js is before , make sure the js follows jQuery and jquery.mCustomScrollbar.

<head> ... <!--the css for jquery.mCustomScrollbar--> <link rel="stylesheet" href="lib/css/jquery.mCustomScrollbar.min.css"/> <!--the css for this plugin--> <link rel="stylesheet" href="css/jquery.emoji.css"/></head><body>...<!--the js for jquery--><script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script><!--(Optional) the js for jquery.mCustomScrollbar's addon--><script src="lib/script/jquery.mousewheel-3.0.6.min.js"></script><!--the js for jquery.mCustomScrollbar--><script src="lib/script/jquery.mCustomScrollbar.min.js"></script><!--the js for this plugin--><script src="js/jquery.emoji.js"></script></body>

调用 invoke 在文本框或可编辑p上初始化emoji initialize emoji on textarea or editable p

$("#content").emoji(options);

参数 options

名称 name 类型 type 默认值 default 说明 desc

button String 触发表情面板的按钮的选择器,如”#btn1”,若指定则将表情选择面板绑定到该按钮,若未指定,则自动创建一个按钮。showTab Boolean true 当只有一组表情时,是否仍然显示Tab。animation String ‘fade’ 表情面板动画效果,可能的值:’fade’:淡入淡出,’slide’:滚动,’none’:无动画。icons Array [] 表情组。icons:{ name } String group(n) 该组表情名称。icons:{ path } String 必填。该组表情路径(表情文件必须是1,2,3…命名)。icons:{ maxNum } Number 必填。该组表情文件名的最大数。icons:{ excludeNums } Array [] 要排除的表情文件集合。icons:{ file } String ‘.jpg’ 表情文件的后缀名。icons:{ placeholder } String ‘#em(n)_{alias}#’ 该组表情插入文本框后的占位标识,必须包含’{alias}’部分,’{alias}’会被自动替换成每个表情的标识。icons:{ alias } String 每个表情对应的标识,若未指定,则为表情文件名(1,2,3…),若指定为一个对象,则会根据对象属性名(1,2,3…)查找属性的值作为表情标识。icons:{ title } Object 每个表情指上去显示的文字,格式:fileName:title, 如:1:’good’。

* n: 分组的次序 index of the group

最终效果

以上就上有关jQuery-emoji表情插件的使用的全部内容,学步园全面介绍编程技术、操作系统、数据库、web前端技术等内容。

抱歉!评论已关闭.