Javascript / jQuery onClick sent sentence with image to input form

I have a page that uses Javascript in order to produce content based on the response of a web service.
The web service returns the content as a sentence ( string ) that sometimes contains an emoji (as image ) and presents the content on the page with a "Try This" button on the side.

When the user presses the button it triggers a function in order to capture the sentence that the web service sent us and place it in an input form.

My issue is that when the user clicks the button the function capture only the sentence without the emoji and place it to the input form.

The function that generates the button with the sentence.

if ( element.Example ) {
        .append('<li><span>'+element.Example.toString()+'</span> <a href="#" class="try-btn">Try This</a></li>');

The function that executes on click

        var $val = $(this).prev('span').text();

35 thoughts on “Javascript / jQuery onClick sent sentence with image to input form”

Leave a Comment