Reputation: 557
Hi can any one help me get all elements in jquery that do not have a class.
I have a list and I want to get all of the that do not have a class and delete it
Here is the code I have so far
var listTableHeaders = $("ROI-List").find("th");
listTableHeaders.not(".sorting").remove();
I realized that there are other classes other than "sorting" as seen in this pic
I can just remove the elements that are not "sorting" or "sorting_disabled" but I am not sure if there are other classes so it would be more convenient to remove the th that do not have any class.
Thank you
Upvotes: 0
Views: 73
Reputation: 320
I belive this will work for what you're trying to do:
$("ROI-List").find("th:not([class])").remove();
Upvotes: 1
Reputation: 51947
Something like this:
$("ROI-List").find("th").each(function () {
if (!$(this).prop('class').length) {
$(this).remove();
}
});
Upvotes: 1
Reputation: 59252
You can filter it
listTableHeaders.filter(function(){
return !$(this).is('[class]');
}).remove();
Upvotes: 3