Skip to content

Instantly share code, notes, and snippets.

@jitter
Forked from cowboy/jquery.ba-nodetype.js
Created November 19, 2010 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitter/705971 to your computer and use it in GitHub Desktop.
Save jitter/705971 to your computer and use it in GitHub Desktop.
/*!
* jQuery nodetype filter - v0.1pre - 11/18/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
* Variation by Anton M.
*/
(function($){
var types = {
element: 1,
text: 3,
comment: 8
};
$.fn.nodetype = function( type ) {
var type = typeof type === "string" ? types[ type.toLowerCase() ] : type;
return jQuery( jQuery.grep( this, function( ele, i ) {
return ele.nodeType === type;
}));
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment