Skip to content

Instantly share code, notes, and snippets.

@onestepcreative
Created April 2, 2014 03:11
Show Gist options
  • Save onestepcreative/9927362 to your computer and use it in GitHub Desktop.
Save onestepcreative/9927362 to your computer and use it in GitHub Desktop.
check if variable is jQuery object
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;
}
@Bronzdragon
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment