I\'m trying to create one event listener to handle all my \"clicks\" by putting it on the body and doing some event delegation. A simple example of what i\'m trying to do i
You should use e.target.parentNode.parentNode.id =='div1' See the demo:
e.target.parentNode.parentNode.id =='div1'
document.body.addEventListener('click', function(e) { if (e.target.parentNode.parentNode.id == "div1") { alert("hi") } })
1 2 3