title: TypeScript: Using jquery $(this) in event
body: <p>HTML:</p>
  
  <pre><code>&lt;div&gt;
  &lt;button data-id="3"&gt;Click Me&lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In classic jQuery I would do:</p>
  
  <pre><code>$("div").on("click","button", test);
  
  function test(){
     alert($(this).data("id"));
  }
  </code></pre>
  
  <p>To get the <code>data-id</code> of the clicked element</p>
  
  <p>In TypeScript (in a class) I use:</p>
  
  <pre><code>class foo { ...
   $("div").on("click", "button", (event) =&gt; this.test());
  
   public test(){
      alert($(this).data("id")); // "undefined"
      console.log($(this));
   }
  
  ....
  }
  </code></pre>
  
  <p>Here I don't get the clicked element - <code>$(this)</code> is the instance of the class.</p>
  
  <p>What did I do wrong?</p>