. Advertisement .
..3..
. Advertisement .
..4..
The button has two states: pressed and not pressed. Pressing the button changes it to the pressed state and unpressing it changes it back to the not pressed state. To Make A Button Do Something In Html, firstly you assign a command to My function. An onclick function allows you to execute an action when something is clicked. Then, continue to assign to onclick. You can refer to the example below:
<script> function myFunction() { alert("ALERT"); } </script>
<button onclick="myFunction">Click</button>
In the case, when a user clicks on the button, they’ll get an alert on their browser that states the button had been click!.
Here is my code