jQuery.proxy() has some of the features I’m looking for, but ideallyI would like to be able to do something like:
$('#some-id').context(function(){
$('.some-class').show();
$('li').css('background','red');
});
The effect of which would be the same as:
$('#some-id .some-class').show();
$('#some-id li').css('background','red');
Does jQuery have a method like my context above?
The closest you can get to that is defining the context in your
jQuerycall:You could also use chaining:
find()end()In both cases, the improvement would be that you only query the DOM once for the initial selector (
'#some-id'in this case).