Skip to content

Instantly share code, notes, and snippets.

@FunnyDewd
FunnyDewd / checkforhandler.js
Created August 29, 2013 00:14
Here's a function which will check jQuery whether a particular element has a namespaced (which is always a good idea) event handler attached to it. It returns true if one exists, false otherwise. Example: checkForHandler("body", "click.foo"); // checks the body element for a click.foo handler
// function: checkForHandler(elem, event)
// - Checks whether the elem has a handler for the namespaced event
// returns: bool - true if the event handler exists, false otherwise
// params: elem - element to query (either dom element or jquery object)
// event - string with the type of element with namespace (click.foo)
var checkForHandler = function(elem, event) {
if ((typeof elem === "undefined") || (typeof event === "undefined")) {
// really?? Y U No Pass Arguments?
return false;
}