On 25 janv. 07, at 10:24, Blair McKenzie wrote:

>Try
>$("#menu li.actif ~ li")

>Translation:
>Find an element with id menu (id by itself is faster than id with tag), then
>find a descendent LI with class actif, and return the preceding element if it
is a LI.

Yes, it works and your explanation of it is pristine. Thanks a lot.

To be more accurate, i found out that it actually returned several (see below)
of the preceding siblings, so i fixed it by adding :last.

Maybe something is amiss: i have 5 <li> in my list. If i select the previous
sibling(s) with your selector when the active <li> is the 2nd or 3rd, all the
previous ones are returned.

However, if the active one is #4 or #5, only the 2 first <li> are found (in
other words li #3 and #4 are not included in the array).

(This was tested on Safari)

PS : Just seeing Sam's reply: yes, it works too! Great!
PPS: apologies if the message isn't correctly placed in the thread, i can't
"reply" at my workplace.

--
  Stéphane Nahmani / sholby
  [EMAIL PROTECTED]
  http://www.sholby.net/

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to