Event handlers

by Haig. Average Reading Time: less than a minute.

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 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.


The onload event handler is used to call the execution of JavaScript after loading:


No comments on ‘Event handlers’

Leave a Reply