use: if( $(this).prev()[0] )
or if( $(this).prev().length ) or if( !$(this).is('first-child') ) -- Ariel Flesler http://flesler.blogspot.com On 11 jun, 11:58, "warren.wessels" <[EMAIL PROTECTED]> wrote: > Hello, > > I've just started using JQuery, and had a quick question that I don't > seem to be able to answer by reading the 1.2 API documentation. > > I have a DOM snippet like: > > <ul> > <li>something</li> > <li>another thing</li> > <li>a third</li> > <li>a final thing</li> > </ul> > > And on mouseover, using the $("li").mouseover event, I am adding a > class to the li using $(this).addClass(...). However, I don't want to > add the class if the li under the mouse is the first li in the ul... > The predicate: > > if( $(this).prev() ) { ... } > > doesn't seem to work as I'd expect (i.e. if this has a previous > sibling), and neither does > > if( $(this).is("ul li:first") ) { ... } > or > if( $(this).is("ul li:eq(0)") ) { ... } > or > if( $(this).is($(this).parent().children()[0] ) { ... } > > Can anyone give me some pointers on how to "detect" that the element > selected is in a certain position in the sibling chain? > > Thank you! > > Warren