That would certainly work, except that you'd need to take out the "." in the hasClass call - it wants a classname, not a selector.
An easier way to do it may be (untested): var $elements = $('#Main > div:not(.test-class)'); alert( $elements.length ); -Mike > From: Arun Kumar > > How can I get DIV elements not having a class ("test-class") > inside a main DIV#Main? > > I am trying > > var count = 0; > $("#Main > div").each(function(){ > if(!($(this).hasClass(".test-class"))) > { > count += 1; > } > }); > alert(count); > > But this is not the correct way I think. > > How can I do it?