<ul> <li>1</li> <li><span>2</span></li> <li>3</li> <li>4</li> </ul> <script> document.getElementsByTagName("ul")[0].onclick = function(e){ alert( [].indexOf.call(this.children, (e ? e.target : event.srcElement) ) ); }; </script>