You can call multiple functions from the same onClick event in JavaScript by chaining the function calls together using the ; operator, like this:

<button onclick="function1(); function2();">Click me</button>

Alternatively, you can define a separate function that calls the other two functions and assign it to the onClick event:

<button onclick="combinedFunction()">Click me</button>
<script>
  function function1() {
    // function 1 code
  }
  function function2() {
    // function 2 code
  }
  function combinedFunction() {
    function1();
    function2();
  }
</script>

You can also use javascript addEventListener method

<button id="myBtn">Click me</button>
<script>
  function function1() {
    // function 1 code
  }
  function function2() {
    // function 2 code
  }
  var btn = document.getElementById("myBtn");
  btn.addEventListener("click", function1);
  btn.addEventListener("click", function2);
</script>

In both cases, both function1 and function2 will be called when the button is clicked.

Also Read:

Categorized in: