$('#mynav li.current').prev().css('blackground', 'black'); MaurĂcio -----Mensagem Original----- De: Alex Para: jQuery (English) Enviada em: segunda-feira, 8 de junho de 2009 20:04 Assunto: [jQuery] Selecting previous element
How do I apply a class to the previous element that's being hovered? Basically the opposite to the following CSS selector: #mynav li.current + li { background:black; } Which would make the li next to the one with a class of 'current' have a black background. Effectively something like: #mynav li.current - li { background:black; } Which would do the same, but to the element immediately before this one. This is impossible with CSS, how would I select it using jQuery? Many thanks, Alex