title: Alerting the this.id keyword returns undefined Javascript
body: <p>I create the same inputbox a couple of times dynamically. When a user presses enter it calls a function. I then test with this code:</p>
  
  <pre><code>function insertComment(){
    alert($(this).attr('id'));
  }
  </code></pre>
  
  <p>But it keeps returning undefined. Here is the syntax I use to create similiar input boxes:</p>
  
  <pre><code>$("#divToAppend").append("&lt;input id='testID' type = 'text' class = 'formatCSS' style = 'margin-top:12px ; ' placeholder = 'Add Comment' onkeydown='if (event.keyCode == 13) insertComment()'&gt;&lt;/input&gt;");
  </code></pre>