safeQuery

Screenshot of safeQuery in action, warning when a selector returns no matches.

Silent failures such as bad selectors are annoying time-wasters. safeQuery warns you when jQuery calls return zero elements, and when attr calls return undefined.

Try the following in the console: $('.oops');

Or, try this one: $('body').attr('madeup');

Tested with jQuery 1.7.2 and should work on all browsers. Just add the safeQuery script after loading jQuery.

Get the code

By the way, you can also load it as a bookmarklet. Just drag the following link to your bookmarks bar: safeQuery