Reputation: 1
In the selector syntax of jQuery $('.string')
, is it possible to specify that the search is performed only within a particular div or element on the page?
I ask because I am using a web application framework which has a bug, namely producing container elements with the same id so when I search by id to find the container programmatically, it returns the first container out of the many containers with the same id.
But the container I want always has a unique class attibute. So if I could select that container and tell jQuery to perform it's queries within that container I would have a solution. Is this possible?
Apologies if a basic question.
Upvotes: 0
Views: 47
Reputation: 700322
You can use the space operator in the selector, i.e. specify that you want to seach for children of the elements with the class:
$('.TheUniqueClass .SomeOtherSelector')...
You can also use an element as scope for the search:
var container = $('.TheUniqueClass');
$('.SomeOtherSelector', container)...
Upvotes: 2