Is this phrase always true?
$("p").click(function(event) {
alert( event.currentTarget === this );
});
Is one method preferred over the other? I like to use $(this) instead of event.currentTarget but can one do better in some conditions? Which is better? Are absolutely the same?
And another nuance – When checking on firebug console.log(this) and console.log($(this)) gives me exactly the same element. If they are the same – what is different? (since I know I can write this $(this).css('color','white') but can’t write this.css('color','white')
Generally, yes, it will be the same. You can make it different by using
$.proxyto manipulate the context, but in practice you probably never will.As to the other question,
thisis a native DOM element, whereas$(this)is a jQuery object wrapping that DOM element. The jQuery wrapper means you can run jQuery functions such ascss, which are not available on native DOM elements.And, to answer the precise wording of your question,
event.currentTargetis normally equal tothis, not to$(this).