I just spent \'hours\' with the following scenario: (all back to the basics)
$(\'#typo\').bind(\'click\' etc ...
I had a typo in the selec
You can use the length of the returned DOM elements as a falsy and throw a new error like so:
error
var el = '#el'; if ($(el).length){ // Do Stuff } else { throw new Error("Element "+el+" Doesn't Exist"); }
OR
// Ignores Empty Selector if ($('#el').length){ // Do Stuff }
I hope this helps!