Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

addEventListener Two Functions

Tags:

javascript

How can I make it so that addEventListener() has two functions inside it?

like image 339
Alex Avatar asked Aug 31 '25 13:08

Alex


1 Answers

Wrap your functions in a function.

const invokeMe = () => console.log('I live here outside the scope');
const alsoInvokeMe = () => console.log('I also live outside the scope'); 

element.addEventListener('event',() => {    
     invokeMe();
     alsoInvokeMe();    
});
like image 79
Sten Muchow Avatar answered Sep 02 '25 04:09

Sten Muchow