When you select an emoticon to insert a text field, a string similar to [Haha] is displayed. Below is a method to convert an emoticon string to an image emoticon, which is common in Weibo or forum, when you select an emoticon to insert a text field, a string similar to [Haha] is displayed. Below is a method to convert an emoticon string to an image emoticon.
The Code is as follows:
Abc
The Code is as follows:
Var face = {'[Haha]': '', '[sweating]':''} // For the complete QQ expression, see the end of this article.
Var reg =/\ [. +? \]/G;
Var str = '[Haha] abc [sweating] [sweating]'; // here is the value of the obtained text field. For simplicity, strings are directly used.
Str = str. replace (reg, function (a, B ){
Return face [a];
});
Document. getElementById ('test'). innerHTML = str;
Qq table package and corresponding face object: http://pan.baidu.com/s/1qWPQbBu