开发者

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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜