can i add multiple events to an event listener js code example
Example 1: addeventlistener javascript multiple functions
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();
});
Example 2: multiple event with javascript
document.getElementById("tg").onclick = function ()
{
my_fun1();
my_fun2();
}
function my_fun1()
{
var x = document.getElementsByClassName("adv")
for(var i=0; i<x.length;i++) {
if (x[i].style.display === "none") {
x[i].style.display = "block"
flag = false
} else {
x[i].style.display = "none"
flag = true
}
}
}
function my_fun2()
{
var x = document.getElementsByClassName("btnpro")
for(var i=0; i<x.length;i++) {
if(flag){
x[i].style.width = "80px";
}else{
x[i].style.width = "60px";
}
}
}