title: Get closest tr inside function js
body: <p>I have this js code :</p>
  
  <pre><code>$(".contenteditable").keyup(function(){
      var data = $(this).text();
      var domId = document.activeElement.id;
      var userId = $(this).closest('tr').find('[type="hidden"]:first').val();
      $.post
      (
          "/users/"+userId,
          {
              data,domId,userId,'_method':'patch'
          },
          function(data)
          {
              console.log(data);
          }
      )
  });
  </code></pre>
  
  <p>Its working ok. However, now I want to make it as function and use it for any page I tried like this:</p>
  
  <pre><code>function keyUpUpdate()
  {
    var data = document.activeElement.textContent;
    var domId = document.activeElement.id;
    var userId = $(this).closest('tr').find('[type="hidden"]:first').val();
  
    console.log(userId);
  }
  </code></pre>
  
  <p>The <code>userId</code> is not working inside this function. 
  How can I get the closest <code>tr</code> and then the first input type hidden value from the active element inside function.</p>