Get Clicked from

You can use for this:


// IE does not know about the target attribute. It looks for srcElement
// This function will get the event target in a browser-compatible way
function getEventTarget(e) {
    e = e || window.event;
    return || e.srcElement; 

var ul = document.getElementById('test');
ul.onclick = function(event) {
    var target = getEventTarget(event);


<ul id="test">
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>


Please note that this is a very basic example and you will likely encounter some problems when you delegate events to elements containing more than one level. When this happens, you will have to traverse the DOM tree upwards to find the containing element.

Leave a Comment