Here, the events are fired inside the browser window, and there may be a single element, a set of elements, or maybe the entire window. There can be many events that can occur, like if the user clicks on some element, or the user presses some key from the keyboard, or the user hovers over some element, or when some element or the body finishes loading, on submission of some form, etc.
There can be events related to –
and many more other events.
Here, we are going to see something, called an event handler, which is some piece of code, that you want to execute in response to that event. This is like there is some code, which is going to execute when some event is triggered. An event handler is also called an event listener.
Here we are going to keep the things simple, and we are going to understand more about the event handling in the DOM ahead.
Here, we are going to have a look at one of the ways, to assign the event handlers, which are essentially some HTML event handler attributes, if the click is an event, the event handler attribute for the click event is going to be on click, or for load event, the event handler attribute is Onload.