Introduce jquery.min.js plugin plugin download plugin official website
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.emoji.js"></script>
<script type="text/javascript">
$(function(){
$("#emoji").emoji({contentel:"#content",
list:[
{
name:"QQ表情",
code:"qq",
path:"./face/emoji1/",
suffix:".gif",
maxnumber:25
},
{
name:"emoji",
code:"em",
path:"./face/emoji2/",
suffix:".png",
maxnumber:22
}
,
{
name:"其他",
code:"other",
path:"./face/emoji3/",
suffix:".png",
max_number:1
}
]
});
$("#send").click(function(){
var content = $("#content").val();
content = replace_em(content);
$("#result").html(content);
$("#content").val('');
});
})
//表情格式替换
function replace_em(str){
str = str.replace(/\</g,'<');
str = str.replace(/\>/g,'>');
str = str.replace(/\n/g,'<br/>');
str = str.replace(/\[qq_([0-9]*)\]/g,"<img src='./face/emoji1/$1.gif' />");
str = str.replace(/\[em_([0-9]*)\]/g,"<img src='./face/emoji2/$1.png' />");
str = str.replace(/\[other_([0-9]*)\]/g,"<img src='./face/emoji3/$1.png' />");
return str;
}
> </script>