<div class="menu">
<span>item1</span>
<span>item2</span>
<span>item3</span>
</div>
document.querySelector(".menu").onclick = (ev) => {
let elem = ev.target;
if (elem.innerText == "item1") {
alert(1);
} else if (elem.innerText == "item2") {
alert(2);
} else if (elem.innerText == "item3") {
alert(3);
}
}