开发者

How can I get the ID of any element clicked within the $(document) in jQuery/js?

$(document).click(function(e){
     alert(e.target); 
});

That alerts [Object HTMLDivElement], is there another variable with the开发者_运维问答 ID of the object?


alert($(e.target).attr("id"));

or

alert(e.target.id);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜