Try $("#el > li > input")
The (rough equiv) long-hand for that would be $("#el").children("li").children("input") So the space ( ) in css is analogous to .find(), and the right-angled-bracket (>) to .children(). - Richard On Wed, Sep 17, 2008 at 11:56 PM, vtjiles <[EMAIL PROTECTED]> wrote: > > I have the fairly simple markup below and am trying to only get only > the checkboxes under the first level LI (Main 1 and Main 2), not the > deeper ones. > > <ul id="el"> > <li> > <input type="checkbox" value="1" /> - Main 1 > <ul> > <li> > <input type="checkbox" value="1" /> - Sub 1 > </li> > <li> > <input type="checkbox" value="1" /> - Sub 2 > <ul> > <li> > <input type="checkbox" > value="1" /> - Sub 2 Sub 1 > </li> > </ul> > </li> > </ul> > </li> > <li> > <input type="checkbox" value="1" /> - Main 2 > </li> > </ul> > > Using $("#el").find("li input") gets all 5 checkboxes. I've tried > multiple variations of find("li input").not("li ul input") as well as > using :not() in the selector which doesn't work. > > One way that did finally work: > var notgroup = $("#el").find("li ul input"); > $("#el").find("li input").not(notgroup) > > Why does it work if there is a variable which is the result of the > selector, but not the selector itself? > > Is there any better way to do this? >