Silent failures such as bad selectors are annoying time-wasters. safeQuery warns you when jQuery calls return zero results.
Tested with jQuery 1.7.2 and should work on all browsers. It's less than 400 bytes, just inline safeQuery.min.js after loading jQuery.
Check out the DEMO page, and type the following in your console: $('.oops')
- Licensed under MIT.
- Thanks @Jake for nudging me in the right direction.
- You should read Paul Irish's awesome post "How to fulfill your own feature request -or- Duck Punching with jQuery!".
- If complex chained selectors are your thing, be sure to check out jQuery-inlog, which provides a deeper look inside the beast.