Is this phrase always true?
$(\"p\").click(function(event) {
alert( event.currentTarget === this );
});
Is one method preferred over the o
Generally, yes, it will be the same. You can make it different by using $.proxy to manipulate the context, but in practice you probably never will.
$(document.body).on('click', $.proxy(function(e) {
console.log(this); // window
console.log(e.currentTarget); // document.body
}, window));
As to the other question, this
is a native DOM element, whereas $(this)
is a jQuery object wrapping that DOM element. The jQuery wrapper means you can run jQuery functions such as css
, which are not available on native DOM elements.
And, to answer the precise wording of your question, event.currentTarget
is normally equal to this
, not to $(this)
.