An event handler can be considered a trigger that executes code when something happens, in the ‘event’ of a click or move your mouse over a link, submit a form etc.
onClick
onClick handlers execute something only when users click on buttons, links, etc. Let’s see an example:
The function specialsauce() is invoked when the user clicks the button. Note: Event handlers are not added inside the <script> tags, but rather, inside the html tags.
onLoad
The onload event handler is used to call the execution of JavaScript after loading:
Leave a Reply