Check ID of a clicked item?
I have a delegate like:
$('#panel').delegate('li', 'click', function(event) {
var target = $(eve开发者_StackOverflow社区nt.target);
// how do we get the ID of 'target'?
var id = target.getId(?);
});
Yeah I'm just not sure how to get 'target's ID, because I want to check if it is a particular element to perform some action on later.
Thanks
Like this:
$('#panel').delegate('li', 'click', function(event) {
var id = event.target.id;
});
You could use the attr() function:
$(event.target).attr('id');
精彩评论