A common effect on Weibo or forums. When you select an emoticon and insert it into the text field, a string similar to [haha] is displayed. The following is a method to convert the emoticon string into a picture emoticon
var face ={'[haha]': '
','[sweat]':'
'} //See the end of this article for complete qq expressions
var reg = /[. ?]/g;
var str = '[haha]abc[sweat][ Sweat]'; //Here is the value of the text field obtained. For simplicity, strings are used directly.
str = str.replace(reg,function(a,b){
return face[a];
});
document. getElementById('test').innerHTML = str;
qq emoticon package and corresponding face object: http://pan.baidu.com/s/1qWPQbBu