-
-
Save jitter/705971 to your computer and use it in GitHub Desktop.
This file contains 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
/*! | |
* 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