JavaScript: The 3 Handling Event Handlers

Method 1: HTML

This is what the code looks like. The JavaScript is embedded within the HTML tag as an attribute.





Method 2: JavaScript

This is what the code looks like for the second example:




Method 3: JavaScript Using the addEventListener() Method

This is what the JavaScript looks like for the third example: