जावास्क्रिप्ट में बटन के क्लिक पर फंक्शन को कॉल करने के लिए, onclick का उपयोग करें। जावास्क्रिप्ट में onclick पर फंक्शन कॉल करने के लिए निम्नलिखित कोड चलाएं:
उदाहरण
<html> <head> <script> function sayHello() { document.write ("Hello there!"); } </script> </head> <body> <p>Click the following button to call the function</p> <form> <input type = "button" onclick = "sayHello()" value = "Say Hello"> </form> <p>Use different text in write method and then try...</p> </body> </html>