Is there any way to use the onclick
html attribute to call more than one JavaScript function?
Greetings! Yes, you can call two JS Function on one onClick.
The first solution to perform multiple onClick events in React is to include all of your actions inside of a function and then call that single function from the onClick event handler. Let's explore how to do that in a React Component: import React from 'react'; function App() { function greeting() { console.
So the answer is - yes you can :) However, I'd recommend to use unobtrusive JavaScript.. mixing js with HTML is just nasty.
onclick="doSomething();doSomethingElse();"
But really, you're better off not using onclick
at all and attaching the event handler to the DOM node through your Javascript code. This is known as unobtrusive javascript.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With