I have the following html
<table>
<tr>
<td headers="Monday"> <div class="foo"> Some stuff </div> </td>
<td headers="Tuesday"> <div class="foo"> Some stuff </div> </td>
<td headers="Wednesday"> <div class="foo"> Some stuff </div> </td>
</tr>
</table>
How can I target the td with Monday headers and remove .foo?
Is this what you meant?
if ($(".foo").text().indexOf('Monday') != -1) {
$("td[headers='Monday']").find(".foofoo").remove();
}
You can remove class with something like this:
$('td[headers="Monday"] > div').removeClass('foo');
$('div','td[headers=Monday]').remove();
Try this...
if($('.foo:contains("Monday")')){
$('table').each(function(){
var mondayHeader = $(this).find('tr.td[headers="Monday"]');
$(mondayHeader).closest('div').removeClass('foofoo');
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.