2016-06-30 8 views
1

私はチャットで顔文字のクリック機能を書いています。私がそれをクリックすると、私のテキストエリアに追加されます。私はチャットにそれを送信したいテキストエリアから。Jqueryはappend function chatをクリックします。

jqueryの私が書いたもの:

$(".emoticon i").click(function() { 
    var e = $(this); 
    // $(".message").append ($(this).data('emoticon')); 
    console.log($(this).data('emoticon')); 
    $("#message").append() .attr(value('emoticon i')); 

})。

<div class="emoji hidden"> 
<div class="emoticon-box"> 
<div class="emoticons"> 
    <div class="emoticon"> 

     <div class="row"> 
     <i class="em em-smiley"></i> 
     <i class="em em-smile"></i> 
     <i class="em em-blush"></i> 
     <i class="em em-relieved"></i> 
     <i class="em em-kissing_closed_eyes"></i> 
     <i class="em em-neutral_face"></i> 
     <i class="em em-sleeping"></i> 
     <i class="em em-flushed"></i> 
     </div>`enter code here` 

Hex of my texarea。

<input id="message" type="text" placeholder="Type your message"></input> 
+0

あなたは$( "em")を試しましたか?$( "。emoticon i")の代わりにclick() – mayk

答えて

0

私はあなたの質問を完全に理解していません。しかし、私はあなたがtextareaのテキストの後ろに顔文字を追加したいと思う。この場合には、次のコードを試している場合:

$(".emoticon i").click(function() { 
var e = $(this); 
var emoticon = $(this).data('emoticon'); 
var text = $(".message").text(); 
var new_message = text+emoticon; 
    console.log($(this).data('emoticon')); 

})。