Edit in JSFiddle

var x = document.querySelectorAll('li');
 [].forEach.call(x , function(el,i) {
       el.onclick=function(){
           alert(el.textContent);
          
       }
         });
<ul>
  <li>Kahve</li>
  <li>Süt</li>
  <li>Soda</li>
</ul>