addEventListener两个函数 [英] addEventListener Two Functions
本文介绍了addEventListener两个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使addEventListener()内有两个函数?
How can I make it so that addEventListener() has two functions inside it?
我试图找到自己的解决方案,但似乎都没有用。
如果可以的话,请举个例子。
I have tried finding my own solution, but none seem not to work. Please give me example if it is possible.
推荐答案
将函数包装在函数中。
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();
});
这篇关于addEventListener两个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文