javascript addeventlistener function code example
Example 1: javascript addeventlistener
var element = document.getElementById("#id");
element.addEventListener('click', function(){
console.log("click");
});
Example 2: javascript addeventlistener
//with jQuery
$("#id / .class").on('click', function(){
console.log("click");
});
Example 3: event listener function called parameters
var someEventHander=function(event,param1,param2){
console.log(event,param1,param2);
}
//add listener
document.getElementById("someid").addEventListener('click',someEventHander.bind(event,'param1','param2'), false);