javascript bind event code example
Example 1: javascript bind event to created element
document.addEventListener('click', function(e){
if(e.target && e.target.id== 'myDynamicallyAddedElementID'){
}
});
$(document).on('click','#myDynamicallyAddedElementID',function(){
});
Example 2: jquery bind click
$( "#foo" ).bind( "click", function() {
alert( "User clicked on 'foo.'" );
});
Example 3: javascript eventlistener
document.addEventListener('click', () => {
});
Example 4: event listener function called parameters
var someEventHander=function(event,param1,param2){
console.log(event,param1,param2);
}
document.getElementById("someid").addEventListener('click',someEventHander.bind(event,'param1','param2'), false);