onClick Event Handler
As the name suggests, onClick is set into motion when a user clicks on something in particular on the webpage. For example, if there was a link on a website splash page and it contained a link to enter the site:
<a href = “firstpage.html" onClick="alert('Welcome!');">Enter Site.</a>
The onClick event handler would display a message box, with the message ‘Welcome!’ and move to the HTML page ‘firstpage.html’.
Although onClick is often used with text links, it is not restricted to them at all. It can be embedded in input objects, like buttons, or with form elements. Additionally, onClick can be used to call functions that are embedded in script blocks, thereby eliminating the need to create an entire block in the middle of an HTML tag.