jQuery - Find out what triggered the event [duplicate]
Possible Duplicate:
Getting th开发者_如何学Goe ID of the element that fired an event using jQuery
How do we find out what triggered an event?
I want to find out if a search input was triggered using the enter key or by clicking on a button.
I assume your binding to the search input using jQuery handlers as such. So just pass the event type along. For more information, pass the entire event object along:
$("input.Search").click(function(event) {
doMySearch(this, "click");
}).keyup(function(event) {
doMySearch(this, "keyup");
});
function doMySearch(element, eventtype) {
...
}
精彩评论