views:

33

answers:

3

Does anyone know how i'd exclude elements from a selection if they have any class whatsoever explicitly attached to them?

Here i'm selecting all columns within the 'tdhead' element, but want to exclude anything I have there that's making use of another class, for example I might have a breadcrumb or toolbar as a single column across the top, in the tdhead.

_create: function () {
var self = this.element;
var headerColumns = self.children("thead").children("tr").children("td").not(".");

headerColumns.css("background-color", "Red");
}

So what's not working is the .not(".") part - whats the correct way to select (or not select) anything with any class?

+4  A: 
.not("[class]")
Codler
A: 
var headerColumns = self.children("thead").find("td").not(".someClass1, .someClass2");

this will get all td's except those with class someClass1 or someClass2. Any question?

Reigel
A: 

Use

var headerColumns = self.children("thead").children("tr").children("td").not('[class]');

.not() may contain a selector string, an element or a function. A lonely dot is no valid jQuery selector. [class] is checking for the existence of a class attribute.

See: .not()

jAndy