jQuery select child element by class with unknown path

According to this documentation, the find method will search down through the tree of elements until it finds the element in the selector parameters. So $(parentSelector).find(childSelector) is the fastest and most efficient way to do this.


$('#thisElement').find('.classToSelect') will find any descendents of #thisElement with class classToSelect.


This should do the trick:

$('#thisElement').find('.classToSelect')

Try this

$('#thisElement .classToSelect').each(function(i){
         // do stuff
});

Hope it will help