/ Published in: jQuery
$('li.current_sub').prevAll("li.par_cat:first");
Tested it with your markup:
$('li.current_sub').prevAll("li.par_cat:first").text("woohoo");
will fill up the closest previous li.par_cat with "woohoo".
Tested it with your markup:
$('li.current_sub').prevAll("li.par_cat:first").text("woohoo");
will fill up the closest previous li.par_cat with "woohoo".
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('li.current_sub').prevAll("li.par_cat:first");
URL: http://stackoverflow.com/questions/2310270/jquery-find-closest-previous-sibling-with-class