Posted By

lamebollock on 01/24/11


Tagged

jquery closest stackoverflow sibling


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

AtticBoy
virendrakryadav


Find closest previous sibling with class


 / Published in: jQuery
 

URL: http://stackoverflow.com/questions/2310270/jquery-find-closest-previous-sibling-with-class

$('li.currentsub').prevAll("li.parcat:first");

Tested it with your markup:

$('li.currentsub').prevAll("li.parcat:first").text("woohoo");

will fill up the closest previous li.par_cat with "woohoo".

  1. $('li.current_sub').prevAll("li.par_cat:first");

Report this snippet  

You need to login to post a comment.