New course! Every coder should learn Generative AI!
Try a free lesson0
Can we assign two function in oniput or onclick tags ?
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...
0
Hi ℋℜҜ
Yes, see below
x.addEventListener(“click”, function() {
function1();
function2();
}
0
visph , thanx very much for helping.
https://code.sololearn.com/WACjk85D721p/?ref=app
0
visph , help me! Can you answer this question ?
https://www.sololearn.com/discuss/2885901/?ref=app