1

Possible Duplicate:
jQuery get all divs which do not have class attribute

I need to select all elements that have no class defined. How do I do that with JQuery?

Community
  • 1
  • 1
Phil
  • 2,143
  • 19
  • 44
  • 3
    `:)` possible duplicate of [jQuery get all divs which do not have class attribute](http://stackoverflow.com/questions/1962247/jquery-get-all-divs-which-do-not-have-class-attribute) **or** http://stackoverflow.com/questions/2715330/jquery-how-to-find-elements-without-a-class-set **or** – Tats_innit Jul 16 '12 at 01:50
  • @GabrielSantos: It is for a weird hack I am working on where in order for it to work, I need to take out items with no class defined on them. – Phil Jul 16 '12 at 01:59
  • @ :) The first you mention is kind of similar but has a different focus while the second one does not seem directly related to my question. Anyway, if anyone wants to close this question, be my guest... – Phil Jul 16 '12 at 02:02

2 Answers2

5
$(':not([class])')

However, note this will also select html, body, head if they don't have a class.

mVChr
  • 49,587
  • 11
  • 107
  • 104
4

This query will select all elements and then filter those that do not have the class attribute: $('*').not('[class]')

KGZM
  • 414
  • 3
  • 5