javascriptjqueryhtmlchat

I have created a chat box with submit button but text area losing focus on clicking submit button


In my mobile site, i have a chat functionality which basically does have a display area, text area to write and a send button to submit text, the issue is when I write text in text area mobile keypad pops up and when I hit send button it loses focus and submits the text and keypad of mobile disappear my requirement is to that keypad should not disappear on clicking send button.


Solution

  • If you are using click() to send messages, you can simply use a 'touchend' event for touch devices:

    $(document).on('touchend', 'selector' ,function(){
        //you code goes here
    });
    

    Now your focus will remain on the text area.