代码很简单,尚未优化。都是想到哪儿写到哪儿;仅作为一个参考。
使用参照示例文件。
css文件样式可自行修改
目前仅针对可编辑DIV ,对于textarea没有太多操作。
html文件<!DOCTYPE html>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | < html > < head > < meta charset = "UTF-8" > < title >Document</ title > < link rel = "stylesheet" href = "myemojiPl.css" > </ head > < body > < div > < div > < div contenteditable = "true" ></ div > < div > < a href = "javascript:void(0);" >'?'</ a >< a >确定</ a > </ div > </ div > < div > < section > </ section > < section ></ section > </ div > </ div > < div > < div > < div contenteditable = "true" ></ div > < div > < a href = "javascript:void(0);" >'?'</ a >< a >确定</ a > </ div > </ div > < div > < section > </ section > < section ></ section > </ div > </ div > < div > < div > < div contenteditable = "true" ></ div > < div > < a href = "javascript:void(0);" >'?'</ a >< a >确定</ a > </ div > </ div > < div > < section > </ section > < section ></ section > </ div > </ div > |
引入jQuery和myemojiPl.js
1 2 | < script src = "jquery.js" ></ script > < script src = "myemojiPl.js" ></ script > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | <script> var emojiconfig = { tieba: { name: "贴吧表情" , path: "img/tieba/" , maxNum: 50, file: ".jpg" , placeholder: ":{alias}:" , alias: { 1: "hehe" , 2: "haha" , 3: "tushe" , 4: "a" , 5: "ku" , 6: "lu" , 7: "kaixin" , 8: "han" , 9: "lei" , 10: "heixian" , 11: "bishi" , 12: "bugaoxing" , 13: "zhenbang" , 14: "qian" , 15: "yiwen" , 16: "yinxian" , 17: "tu" , 18: "yi" , 19: "weiqu" , 20: "huaxin" , 21: "hu" , 22: "xiaonian" , 23: "neng" , 24: "taikaixin" , 25: "huaji" , 26: "mianqiang" , 27: "kuanghan" , 28: "guai" , 29: "shuijiao" , 30: "jinku" , 31: "shengqi" , 32: "jinya" , 33: "pen" , 34: "aixin" , 35: "xinsui" , 36: "meigui" , 37: "liwu" , 38: "caihong" , 39: "xxyl" , 40: "taiyang" , 41: "qianbi" , 42: "dnegpao" , 43: "chabei" , 44: "dangao" , 45: "yinyue" , 46: "haha2" , 47: "shenli" , 48: "damuzhi" , 49: "ruo" , 50: "OK" }, title: { 1: "呵呵" , 2: "哈哈" , 3: "吐舌" , 4: "啊" , 5: "酷" , 6: "怒" , 7: "开心" , 8: "汗" , 9: "泪" , 10: "黑线" , 11: "鄙视" , 12: "不高兴" , 13: "真棒" , 14: "钱" , 15: "疑问" , 16: "阴脸" , 17: "吐" , 18: "咦" , 19: "委屈" , 20: "花心" , 21: "呼~" , 22: "笑脸" , 23: "冷" , 24: "太开心" , 25: "滑稽" , 26: "勉强" , 27: "狂汗" , 28: "乖" , 29: "睡觉" , 30: "惊哭" , 31: "生气" , 32: "惊讶" , 33: "喷" , 34: "爱心" , 35: "心碎" , 36: "玫瑰" , 37: "礼物" , 38: "彩虹" , 39: "星星月亮" , 40: "太阳" , 41: "钱币" , 42: "灯泡" , 43: "茶杯" , 44: "蛋糕" , 45: "音乐" , 46: "haha" , 47: "胜利" , 48: "大拇指" , 49: "弱" , 50: "OK" } }, AcFun:{ name : "AcFun表情" , path : "img/AcFun/" , maxNum : 54, file : ".png" } }; $( '.Main' ).myEmoji({emojiconfig : emojiconfig}); $( '.Main3' ).myEmoji(); $( '.Main2' ).myEmoji(); </script> </body> </html> |
表情配置项说明
1 2 3 4 5 6 7 8 9 10 11 | /** * emoji表情配置 * 表情组 : { * name : 名称, * path : 路径, * maxNum :数量, * file : 后缀名, * alias : { }每个表情对应的标识,若未指定,则为表情文件名(1,2,3...)+file, * title : { }每个表情指上去显示的文字,格式:fileName:title * } */ |
有什么改善建议请指出
第一次弄这些,代码太不规范了。。。
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com