Created
April 2, 2014 03:11
-
-
Save onestepcreative/9927362 to your computer and use it in GitHub Desktop.
check if variable is jQuery object
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
var isjquery = function(data) { | |
// If data is already a jQuery object | |
if(data instanceof jQuery) { | |
// Do nothing different | |
data = data; | |
// Otherwise | |
} else { | |
// Convert to jQuery object | |
data = $(data); | |
} | |
// Return jQuery object | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, this makes sense, except for the method name. Shouldn't it be called "makejquery" instead, since you're not returning a true/false value, but instead returning a jquery object?