Can we assign two function in oniput or onclick tags ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we assign two function in oniput or onclick tags ?

23rd Jun 2021, 4:45 AM
Harsh
Harsh - avatar
4 Answers
+ 3
if you use addEventListener() to register event handler function, you could add how many you want: x.addEventListener("click", function1); x.addEventListener("click", function2); (no need to create a third function to call your two others) if you use event attribute/properties, you must create a third function wich call each of the function you want to run on event: x.onclick = function(evt) { function1.call(this,evt); function2.call(this,evt); }; however, you are obviously not mandatory to bind 'this' object and/or event object...
23rd Jun 2021, 5:04 AM
visph
visph - avatar
0
Hi ℋℜҜ Yes, see below x.addEventListener(“click”, function() { function1(); function2(); }
23rd Jun 2021, 4:51 AM
Ollie Q
Ollie Q - avatar
23rd Jun 2021, 1:09 PM
Harsh
Harsh - avatar
0
visph , help me! Can you answer this question ? https://www.sololearn.com/discuss/2885901/?ref=app
19th Sep 2021, 2:09 PM
Harsh
Harsh - avatar