search

Home  >  Q&A  >  body text

javascript - Please tell me about the problem of emoji output on the WEB.

I am making a web chat room application, and today I want to add the function of sending emoji. I encountered two problems while writing JS.
Question 1: When adding a click event to the traversed emoji image, you want to get the text content of the writing panel #write first. Use getElementById to get "", but you can use $("#write").val( )Get the previously written content;
Question 2: If you have written content before clicking the emoji, the emoji cannot be printed?

Code: (Sorry, it seems a bit uncomfortable to use JS and Jquery together)

function clickEmoj(){//Generate and destroy emoj
            var emojs = ['
怪我咯怪我咯2706 days ago807

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-06-30 09:58:01

    My implementation logic is very simple

        $('#emoji span').click(function(){
            var val = $('.chat-active input[type=text]').val();
            $('.chat-active input[type=text]').val(val+$(this).text()); 
            $('#emoji').css('display','none');
        });

    reply
    0
  • Cancelreply