user516883
user516883

Reputation: 9388

jquery remove all items within div that does not have a class

I have a asp.net Listview that is generating extra elements, good thing is the elements that I do want have a class name. How do I remove the s without the specific class that i need in jquery thanks!

Upvotes: 1

Views: 479

Answers (3)

Ghostman
Ghostman

Reputation: 6114

$('div:not([class])').remove();

Upvotes: 0

jli
jli

Reputation: 6623

Use the :not selector:

$("div:not([class])").remove();

Edit: jsfiddle.

Upvotes: 5

Daff
Daff

Reputation: 44215

class is just an attribute so you can select each one that doesn't have the attribute:

$('div:not([class])').remove()

Upvotes: 2

Related Questions