What is onclick event in JavaScript?

The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse.


You can put your validation, warning etc., against this event type.

Live Demo

            function sayHello() {
               alert("Hello World")
      <p>Click the following button and see result</p>
         <input type="button" onclick="sayHello()" value="Say Hello" />