1. Introduction of CSS Files
<rel= "stylesheet" type= "text/css" href= " Jquery.sinaEmotion.css ">
2. Introduction of Jquery.js and JQuery.sinaEmotion.js
<src= "Jquery.min.js"></script>< src = "jquery.sinaEmotion.js" ></script >
3. HTML code
<formclass= "Publish"> <DivID= "Result"></Div> <textareaclass= "Content"ID= "Content">Welcome to use jquery Sina emotion[hehe]</textarea><BR> <inputclass= "Face"type= "button"value= "expression"> <inputclass= "Submit"type= "button"value= "Parse"> </form>
which
<id= "Result"></div>
is used to show the parsed expression.
<class= "Content" id= "Content"> Welcome to jquery Sina emotion[hehe]</textarea>
TextArea used to display the text field that sends emoticons (you can also use input type= "text")
One thing to note is that the Text field or text box that displays the expression needs to be in the same form as the Send emoticons button. Because in JQuery.sinaEmotion.js, the expression is displayed by locating the textarea or input in the form form where the target is located.
function (target) { = target function() { return $ (this). Parents (' form '). Find ( ' textarea,input[type=text] '). EQ (0); };
Next, you add a click event by binding the ". Face" class name to the emoticon button.
$ ('. Submit '). Bind ({ function() { var content = $ (' #content '). Val () ; $ (' #result '). HTML (content). Parseemotion (); } ); $ ('. Face '). Bind ({ function(event) { if(! $ (' # Sinaemotion '). Is (': Visible ')} { $ (this). Sinaemotion (); Event.stoppropagation (); } }
Demo Address:
Http://pan.baidu.com/s/1bnnr1tt
jquery Sina Weibo emoticons plugin tutorial