2

I am trying to insert the emoji(s) into my input field called #usermsg when it is clicked.

The emoji does not show up in the input field.

I have added .clone() to the jQuery function so that the emoji would not disappear when clicked.

enter image description here

HTML emoji:

<a id="smiley" title="smiley" href="#" >&#128515;</a>

HTML input field:

<input name="usermsg" type="text" id="usermsg"/>

jQuery function:

//Add emoji when clicked
$("#smiley").click(function(){
    $('#smiley').clone().append('#usermsg');
  });

I've tried adding .val(); after the .append('#usermsg'); However this still does not work for me.

If someone could lead me in the right direction.

Thank you.

Zaedian
  • 251
  • 5
  • 24

1 Answers1

0

Answer with help from @guradio and @Alexis

Change:

$('#smiley').clone().append('#usermsg');

To:

$('#usermsg').val($('#usermsg').val() + $('#smiley').html());
Zaedian
  • 251
  • 5
  • 24