samp,
https://learn.javascript.ru/event-delegation
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.done {
background-color: #FF00FF;
}
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
var todo = document.getElementById("todo");
todo.addEventListener("click", function(event) {
event.preventDefault();
var target = event.target;
while (target != todo) {
if (target.tagName == "LI") {
target.classList.toggle("done");
break
}
target = target.parentNode
}
})
});
</script>
</head>
<body>
<ul id="todo">
<li><a href="home.htm">Home</a></li>
<li><a href="products.htm">Products</a></li>
<li><a href="services.htm">Services</a></li>
<li><a href="about.htm">About Us</a></li>
<li><a href="contact.htm">Contact</a></li>
</ul>
</body>
</html>