Получите все li nodes
и добавьте click events
к каждому nodes
.
var lis = document.getElementById("div").getElementsByTagName("li")
for(var i=0;i<lis.length;i++){
lis[i].addEventListener('click', function(e){
alert(e.target.textContent);
})
}
// As if you want to have single click event on ul itself
document.getElementById("ul").addEventListener('click', function(e){
alert(e.target.textContent);
})
ul li {
background: #cce5ff;
margin: 5px;
cursor:pointer;
}
<div id="div">
<ul >
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</div>
<p> As if you want to have single click event on ul itself</p>
<hr>
<ul id="ul">
<li>X</li>
<li>Y</li>
<li>Z</li>
</ul>