Created
May 24, 2011 16:48
-
-
Save bruno-c/989096 to your computer and use it in GitHub Desktop.
jQuery plugin that creates a 'subquery' object - basically lets you work with a specific chunk of elements or with detached elements in a way that's less annoying.
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.fn.subquery = function(){ | |
var ctx = $(this); | |
return function(){ | |
return arguments.length ? ctx.find.apply(ctx, arguments) : ctx; | |
}; | |
}; | |
// Given something like: | |
// <article id="article1"> | |
// <h3>foobar</h3> | |
// </article> | |
// var $$ = $('#article1').subquery(); | |
// console.log( $$('h3').text() ); --> 'foobar' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment