Reputation: 8970
I have a page with several tables. I am allowing a user to add data points to the page if they haven't yet been used on the page.
All of the tables have a column with the class of field
.
When I am providing them with the list of options to add, I want to ignore a specific table.
Basically, I want to loop over all .fields
that are not in the table #groupTable
.
$('.field:not(#groupTable)').each(function(){
if(parseInt($(this).text()) == parseInt(fieldID)){
inUse = true;
}
});
Is there something I am missing from my selector? With how it is currently shown, it is including results from the #groupTable
.
Upvotes: 1
Views: 46
Reputation: 241118
You are trying to exclude .field
elements with an id
of #groupTable
.
Try excluding table elements with an id
of #groupTable
, then selecting the .field
descendant element(s):
$('table:not(#groupTable) .field').each(function () {
// ...
});
Upvotes: 2
Reputation: 48
I created a jsfiddle
This is the selector: .field:not(#groupTable .field)
Upvotes: 0
Reputation: 9583
Yes, you are missing something, your selector excludes the table itself, to exclude the columns from within it I would think your selector should be:
'.field:not(#groupTable .field)'
Upvotes: 2