Best syntax to test event target in jQuery
<p>I have a keypress handler bound to all input elements on a form, and I need to perform different operations depending on which element received the keypress. All 3 variations below work, but I'd like to know if one (or something else) is preferred and why.</p>

<pre><code>$(':input').keypress(function(e) {
  if($(this).attr('id') === 'foo')  // option 1
    console.log('foo'); 
  if($(this)[0] === $('#bar')[0])   // option 2
    console.log('bar');
  if(e.target === $('#baz')[0])     // option 3
    console.log('baz'); 
});
</code></pre>

<p>There are few elements on the page, so performance isn't really a concern. It's more of a stylistic/standards/readability issue.</p>
