Tuesday, June 5, 2012

jquery - get id of element that fired event

In jquery, event.target.id always refers to the element that triggers the event (or selected event). Sample below


$(document).ready(function() {
    $("a").click(function(event) {
        alert(event.target.id);
    });
});

1 comment: