javascript – js – append() not working

Question:

Doesn't add emoticons to the textarea (more precisely, their text designations), what's the problem?

I'm not strong in js, but by scientific poke it turns out to send emoticons, but the text is not sent, or vice versa.

jquery-1.7.1.js is included in the header

<textarea class="textarea"> </textarea> <!---  name="textarea" contentEditable="true" --->
<input class="btnWrite" type="submit" value="TO SEND"> 

<div class="smail">
    <div class="smail_block">
     <li><img src="img/smiles/1.gif"  onClick="javascript: $('.textarea').append('::1::');" /></li>
     <li> ------------------- еще 18 смайлов ---------------- </li>
     <li><img src="img/smiles/20.gif" onClick="javascript: $('.textarea').append('::20::');" /></li>
    </div>
</div>

<script>
$(document).ready(function() { 
 //Отправка сообщений----------------------------------------------------------------------
 function WriteMesseg(){
     //передаем текст из поля textarea в переменную textarea
     //var textarea = $('.textarea').val(); 
     var textarea = $('.textarea').val(); //.text()
     //записываем в скрытый див для передачи
     $("#messedg").html(textarea);


     //очищаем textarea
    // $('.textarea').val('');//.html(" ");   .empty();  .clear() .text('')  .val('')
       $('.textarea').val('');
     // $('.textarea').text('');
     // $('.textarea').empty();
     // $('.textarea').clear();

    }
    //выполнение функции WriteMesseg по нажатию кнопки с классом .btn_go
    $(document).on('click', '.btnWrite',WriteMesseg);

});
</script> 

Answer:

 onClick="javascript: $('.textarea').val($('.textarea').val()+'::1::')"

see how it works

Scroll to Top