I have a situation where all my selectors all have the same ancestor element
$('#foo .bar')...
$('#foo .some_class')...
$('#foo .some_other_class')...
I was wondering if there was a way to tell jQuery to always assume the selector will descend from #foo? So something like
$.ancestorWillAlwaysBe('#foo');
$('.bar')...
$('.some_class')...
$('.some_other_class')...
Looks like you are lazy to type all those
#foo. Here’s a way to do that in a simpler way:Or if you really that lazy, you can do this:
DEMO: http://jsfiddle.net/DerekL/agnHy/