I have the HTML below:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div>
<section>
<a>first</a>
<a>second</a>
</section>
</div>
<section>
<a>third</a>
<a>fourth</a>
</section>
<section>
<div>
<a>fifth</a>
<a>sixth</a>
</div>
</section>
<script src="ex-2-a.js"></script>
<!--<script src="ex-2-b.js"></script>-->
</body>
</html>
I'm looking to add only one event listener to the whole document that would catch only 'a' tags that have a 'div' as ancestors. This means that if I click first, second, fifth and sixth I would get a message saying "cool".
Any ideas on that matter since there's no id and working with only tagnames?