Reputation: 12512
I need to remove a class from any place withing a table if another class is not found inside a span that is residing inside that table.
Basically I need to do the opposite of hasClass but I'm not sure what I'm doing wrong. Here's my code:
if ($("#nyTable").find("span").not("ui-icon-triangle-1-s")) {
$("#nyTable").find("td").removeClass("redText");
}
<table>
<tr>
<td>as</td>
<td>asd</td>
<td>werwe</td>
</tr>
<tr>
<td><span class="ui-icon-triangle-1-s">asd</span></td>
<td><span class="ui-icon-triangle-1-s">asd</span></td>
<td><span class="ui-icon-triangle-1-s">asd</span></td>
</tr>
</table>
UPDATE: I need to make sure that this class .ui-icon-triangle-1-s does not exist anywhere in the table.
Upvotes: 1
Views: 110
Reputation:
if (!$("#nyTable span.ui-icon-triangle-1-s").length) {
$("#nyTable td.redText").removeClass("redText");
}
Upvotes: 1
Reputation: 19425
What about somthing like this?
//$('#nyTable span:not('ui-icon-triangle-1-s')').removeclass('redText');
$('#nyTable span').not('ui-icon-triangle-1-s').removeclass('redText');
This is just "pseudocode" - this exact code will probably not work, but try something along these lines.
Upvotes: 1
Reputation: 5931
Try it this way, you forgot your . for the class
if ($("#nyTable").find("span:not(.ui-icon-triangle-1-s)")) {
$("#nyTable").find("td").removeClass("redText");
}
Upvotes: -1