When the page loads in a browser, when the user moves the mouse over a link, when a video has finished loading, or when a form is submitted are events. So if you want to take care of a task when something happens you have to capture that event, and that’s done through a process called event registration.
This means telling the browser that you want to do something when an event takes place, and there’s several ways of doing that. Some are more compatible with older browsers than others.
The first (but legacy) way of doing this is by using tag attributes, and this works pretty simply.
<img id="image1" scr="image1.jpg" onclick="alert("hello world")" />