Created
December 13, 2009 13:48
-
-
Save georgebrock/255420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Get a warning when jQuery finds no matches for a selector | |
| Handy for debugging, although I wouldn't want it in production | |
| */ | |
| jQuery.oldFind = jQuery.find; | |
| jQuery.find = function(sel) { | |
| var result = jQuery.oldFind.apply(jQuery, arguments); | |
| if(typeof(sel) == "string" && result.length == 0) { | |
| console.warn("Nothing matches selector: ", sel); | |
| } | |
| return result; | |
| } | |
| jQuery(function($) { | |
| $("div"); // Finds stuff | |
| $("foo"); // Finds nothing | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment