How can I know which element fire the event from js?
开发者_如何转开发I have somethings like this:
$('#eventFire').dblclick(function(){
EventHandler.dblclickListener();
});
I want the EventHandler
listen the double click event, and I want the EventHandler
know which element from the page is fire this event, how can I do so?
The event object is passed as the first argument to your handler, like this:
$('#eventFire').dblclick(function(e){
//e.target fired the event, this refers to the #eventFire element
});
So inside the handler, the e.target
could be the element with the handler or a child (from which the even bubbled), and this
will refer to the element the handler is on, #eventFire
in this case.
精彩评论