Reputation: 329
For each table of class 'y', if table does not contain descendant with class 'x', select descending th and td elements then remove their width attribute.
Here's what I have so far:
$(document).ready(function(){
$('table.y').has(':not(.x)').find('td').removeAttr('width')
$('table.y').has(':not(.x)').find('th').removeAttr('width')
});
Upvotes: 2
Views: 55
Reputation: 144689
You can use not
method and :has
selector, for excluding elements, first you should use not
method or :not
selector.
$(document).ready(function(){
$('table.y').not(':has(.x)').find('td, th').removeAttr('width')
});
Upvotes: 4