Adding an event listener to an element that doesn't exist yet code example
Example: Adding an event listener to an element that doesn't exist yet
// You need to add the event listener when the element is created.
function createEventListener() {
var node = document.createElement('div');
if (node) {
node.addEventListener('click', function() {
console.log('Clicked Node');
});
} else {
console.error('No node');
}
}