Possible Duplicate:
Getting the 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) {
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With