title: How to save the value of an input for a function?
body: <p>I'm new to PHP and SQL and JQUERY/JS. I'm trying to make is so that when a person press's enter(while in an input field) the same thing occurs as if they hit the existing button.</p>
  
  <p>This is the original button code: </p>
  
  <pre><code>$(document).on("click", '.submit', function(event) { 
    var to_user_id = $(this).attr('id');
    to_user_id = to_user_id.replace(/chatButton/g, "");
    sendMessage(to_user_id);
  });
  </code></pre>
  
  <p>My Attempt at making it so that enter did the same thing as the above code:</p>
  
  <pre class="lang-js prettyprint-override"><code>$('#chatMessage3').keyup(function(e) {  
    if (e.keyCode == 13) {   
      var to_user_id = $(this).attr('id');
  
    sendMessage(to_user_id);  
  }
  </code></pre>