Prev Demo
JavaScript
>
How To Execute A Javascript Function On Click Of The Element In Javascript?
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Onclick</h1> <script> function TestFunction() { alert("Click event fired.") } </script> <input type="button" id="btnTest" onclick="TestFunction()" value="Click me" /> <p><strong>Note: </strong>Click on button to fire the alert.</p> </body> </html>
Note: We DO NOT save your trial code in our database.
Output