I need to capture an anchor node with an image inside using event delegation.
document.addEventListener(
'click',
function(event) {
console.log(event.target);
return true;
},
false
);
<a href="#" class="link">
<img src="http://placehold.it/100x100" alt="">
</a>
event.target is always img.
How can check if the click was made on a node with class .link?
UPDATE: to be clear here is an example with jQuery
When I use jQuery.on() there is a
node in this
property in callback fucntion, not img
node. With pure JS I can determine initial target only.