Is it possible to assign 2 functions to a single button?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Is it possible to assign 2 functions to a single button??

18th Jan 2018, 11:51 AM
Dlite
Dlite - avatar
2 Answers
+ 10
Short answer is yes and the proper way would be saying attaching 2 event listeners to the button. If it's for a same event (e.g. onClick), perhaps you can wrap it into a single function and call any number of functions inside it. 😉
18th Jan 2018, 3:27 PM
Zephyr Koo
Zephyr Koo - avatar
+ 2
Yes, it is possible to call two function with one single button. Assume you have 2 function a() and b(). Therefore, you can use them like this :- <button onclick="a();b();">Calling<button>
18th Jan 2018, 11:56 AM
Akash Pal
Akash Pal - avatar