The onClick event is the commonly used events in JavaScript. It action occurs when an element is clicked .
How to onClick event works
First, you have to select the element to which you want to add the onClick event. we would use the <button> element.
now, add an attribute to your element,an attribute is called onClick. This attribute’s value should to run when the element is clicked.
Here’s what our code would look like with the onClick event added:
Simple project on click event
Make a file with name index.html
After clicking this button the event has occurs