Skip to content

Instantly share code, notes, and snippets.

@quickredfox
Forked from scottgonzalez/jquery-element.js
Created December 15, 2010 20:35
Show Gist options
  • Save quickredfox/742568 to your computer and use it in GitHub Desktop.
Save quickredfox/742568 to your computer and use it in GitHub Desktop.
function element(value, context) {
var ret = $([]); // $(context) ?
if (value.jquery) {
ret = value;
} else if (value == 'parent') {
ret = $(context).parent();
} else if (value == 'clone') {
ret = $(context).clone().removeAttr('id');
} else if (value == 'window') {
ret = $(context).window(); // requires .window() plugin
} else if (value.nodeType || typeof value == 'string' || $.isArray(value)) {
ret = $(value, context);
} else if ($.isFunction(value)) {
ret = value(context);
}
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment