Reputation: 4044
If I want to select the elements that don't have a class (but may have an ID), the following
$(".entry-container ul:not([class])").addClass("list type-1");
works fine.
If I want to select the elements that don't have an ID (but may have a class) the following
$(".entry-container ul:not([id])").addClass("list type-1");
works fine.
But what if I want to select all the elements that don't have a class AND and an ID?
Upvotes: 2
Views: 409
Reputation: 144659
$(".entry-container ul").not("[id][class]").addClass("list type-1");
Using .filter()
method:
$(".entry-container ul").filter(function() {
return this.id === '' && this.className === '';
});
Upvotes: 3
Reputation: 7566
see these: http://www.nicksays.co.uk/css-boolean-selectors/
$(".entry-container ul:not([class]) .entry-container ul:not([id])").addClass("list type-1");
Upvotes: 1
Reputation: 123739
Try
$(".entry-container ul:not([id],[class])").addClass("list type-1");
Upvotes: 1