How to pass local variable value from function to addEventListener function?
Here is code for example(JavaScript),
function f(){
var x = new Audio('Audio URL')
var divID = document.getElementById('id of a div');
if(divID){
divID.addEventListener("webkitAnimationEnd",g);
divID.addEventListener("animationend",g);
}
}
function g(){
//Code that uses variable x value and functions i.e x.pause() or x.play()
}
How to pass the variable x value in function f() to function g() in addEventListener?
addEventListenershould be a quoted string.