Try $('div.first:not(.second)') and $('li:not(.jq-first)') (without tag names in the :not() selector)

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Feb 1, 2009, at 12:40 PM, Javier Martinez Fernandez wrote:


I'm having some problems using the "not" selector on my jquery code. I have elements that have one classname "first" and only one of them has a second classname "second" (that is used in many other elements). I want to select the elements that have the "first" but not the "second".

The selector I have is:

$('div.first:not(div.second)')

An the selector is not working. I'm using it incorrectly or is a bug?

PD: you can test this problem in jquery.com page. There are 2 elements "li" that has the classnames "jq-first". You can select all "li" elements on the page and there are 52. So, you can select all "li" elements on the page without the elements with "jq-first" classname, and the result must be 50 elements. But when I execute:

$('li:not(li.jq-first)')

There are no elements selected.

Reply via email to