JQuery - find out what caused the event

Possible duplicate:
Getting the id of the element that triggered the event using jQuery

How to find out what caused the event?

I want to know if the search input was entered using the enter key or by pressing a button.

+6
jquery events triggers
source share
1 answer

I assume that you are attached to search input using jQuery handlers per se. So just pass in the type of event. For more information, pass the entire event object:

$("input.Search").click(function(event) { doMySearch(this, "click"); }).keyup(function(event) { doMySearch(this, "keyup"); }); function doMySearch(element, eventtype) { ... } 
+4
source share

All Articles