|Don't click on this anchor.|
I set up a demo page so I can remind myself which is which.
The second link, which uses the onclick attribute, also results in the Window object being this inside the function. But the event is populated with a MouseEvent and the source node is the anchor tag. That's all good information.
The third form, which set the click event handler using jQuery, also gives good information but in a slightly different way. Inside the function, this refers to the anchor tag instead of the Window. The event object is a jQuery event object, which wraps the original event. This is nice because jQuery events tend to be more standard across different browsers.
The bottom line is that the second and third forms are better because they give you more complete information about the click. But they do so in different ways - ways of which you must be aware! The first form should probably be avoided in most cases.
I'll probably have to refer back to this post myself in a few months to remember the rules. One of the best things about writing a blog is that it documents information for your future self. Often I search my own posts for some bit of information that I know I wrote about once but can't remember.
My comics don't really contain any useful information but sometimes I look back at them too. You should look at the one for today:
|Amphibian.com comic for 29 May 2015|