我有下面的HTML:
<!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>
我希望在整个文档中只添加一个事件侦听器,只捕获以“div”作为祖先的“a”标记。
这意味着,如果我点击第一,第二,第五和第六,我会收到一条信息说“酷”。
你有什么想法吗?因为没有身份证,只和
标记名?