Possible Duplicate:
Jquery: Selection within a selection
Consider this code:
var $el = $('<div class="test"><div>Foor</div></div><div class="test"><div>Bar</div></div><div class="other">Leave it!</div>');
// won't work
$el.find('div.test').css('color','red');
$('body').append($el);
jsFiddle:
How can I access <div class="test"> elements using jQuery?
Please note I would like to access .test elements before using them in document.
I know I can create wrapper for divs, but I really would like to avoid it.
In your code
.testis a root level element. Hence you should be using.filternot.find..findis for descendants.