I am collecting page button click events. Normally i am collecting the objects from statically created DOM elements. By using,
$('input[type=button]').each(function () {
$(this).bind('click', function () {
Console.log(this);
});
});
But when i add a new button dynamically like,
vvar newBtn = document.createElement('input');
newBtn.type = 'button';
newBtn.setAttribute('id', 'JgenerateBtn');
newBtn.setAttribute('value', 'JgenerateBtn');
newBtn.onclick = function () { alert('javascript dynamically created button'); };
var holderDiv = document.getElementById('holder');
holderDiv.appendChild(newBtn);
after this code, New Button is created and event also triggering, But i cant able to get the Event object by using, same above code.
$('input[type=button]').each(function () {
$(this).bind('click', function () {
Console.log(this);
});
});
Please provide suggestion to get the dynamically created elements event object.