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

相关文章:

  • 2022-12-23
  • 2021-06-19
  • 2021-06-02
  • 2021-12-05
  • 2021-04-05
  • 2021-12-14
  • 2021-09-17
  • 2021-08-25
猜你喜欢
  • 2021-05-31
  • 2022-12-23
  • 2021-09-03
  • 2022-02-15
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案