1// You need to add the event listener when the element is created.
2function createEventListener() {
3 var node = document.createElement('div');
4 if (node) {
5 node.addEventListener('click', function() {
6 console.log('Clicked Node');
7 });
8 } else {
9 console.error('No node');
10 }
11}