How to call multiple JavaScript functions in onclick event?

JavascriptWeb DevelopmentFront End Technology

To call multiple JavaScript functions in on click event, use a semicolon as shown below −

onclick="Display1();Display2()"

Example

Live Demo

<html>
   <head>
      <script>
         function Display1() {
            document.write ("Hello there!");
         }
         function Display2() {
            document.write ("Hello World!");
         }
      </script>
   </head>
   <body>
      <p>Click the following button to call the function</p>
      <form>
         <input type = "button" onclick = "Display1(); Display2()" value = "Result">
      </form>
   </body>
</html>
raja
Published on 29-Jan-2018 15:25:39
Advertisements