I know that E is short for ‘event,’ but it’s still not clear to me why I need to use it? I tried passing other letters through the function and it didn’t seem to work. Are there other situations where I need to pass a specific letter into a function?
$("#myThing").click(function (e) {
var hit = $(e.target);
hit.css('color','blue');
});
This does the same thing:
$("#myThing").click(function () {
$(this).css('color','blue');
});
When should I use $(this) versus ‘e’?
Thank you!
You don’t need to pass a specific letter through the function.
is identical to
etc.
The difference between using
$(e.target)and$(this)can be quite more significant though, sincethiswill always be the element on which the event is tied, whilee.targetwill be the specific element that was clicked, even though it’s located inside thethiselementHope that made sense