Check this example:
$('button').bind('click focus', function() {
// Did I click or focus?
});
Is there a way to work that out when binding multiple events to one handler?
This may work, but it is kind of ugly:
var eventType;
$('button').click(function() {
eventType = 'click';
do();
});
$('button').focus(function() {
eventType = 'focus';
do();
});
function do() {
alert(eventType);
}
You can use
event.typeon the event object (the first param passed to the handler), like this: