jqueryFace表情包使用

实现如上图所示的效果

首先下载jquery.qqFace.js与jquery-browser.js

需要修改表情包显示的位置可以在jquery.qqFace.js中修改var top = offset.top + $(this).outerHeight();

html中的textara改成<div class="text" style="background: #c0c0c0;height: 120px;" contenteditable="true" id="textarea"></div> 

jquery.qqFace.js中修改insertAtCaret函数中else里面的值为textFeildValue = textFeildValue.replace(/\</g,'&lt;');
            textFeildValue = textFeildValue.replace(/\>/g,'&gt;');
            textFeildValue = textFeildValue.replace(/\n/g,'<br/>');
            textFeildValue = textFeildValue.replace(/\[em_([0-9]*)\]/g,'<img src="static/arclist/$1.gif" border="0" />');
            textObj.innerHTML+=textFeildValue; 

最后在提交的时候修改replace_em函数为function replace_em(str){
            /* str = str.replace(/\</g,'&lt;');
            str = str.replace(/\>/g,'&gt;');
             */str = str.replace(/\n/g,'<br/>');
            str = str.replace(/\[em_([0-9]*)\]/g,'<img src="static/arclist/$1.gif" border="0" />');
            return str;
        }

最后大功告成,不知道这样改会不会出现什么问题,但是目前使用良好。

转载于:https://my.oschina.net/blr/blog/680611

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值