简体   繁体   中英

Trigger the textarea message when clicking on href link

I am trying to customize intercom plugin on a wordpress website. I need to trigger a message when clicking on a href link, (so simulate enter key on the textarea).

This is code used:

jQuery('body').on('click', '.start-chat-btn-advice', function () {
  var e = jQuery.Event("keydown");
  e.which = 13;  
  jQuery("textarea").trigger(e);            
}); 

Sounds like you need

<form action="chat" id="form1">
  <div id="container">
    <textarea id="chatText"></text>
    <a href="#" class=".start-chat-btn-advice">Click</a>
  </div>
</form>

$(function() {
  $("#container").on("click",".start-chat-btn-advice",submitIt);
  $("#chatText").on("keydown",function(e) { 
    if (e.which==13) submitIt() 
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM