I'm using that jQuery Vertical Menu Library www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm I want to accomplish the selection of the selected path. Let's say that I go through that menu (in the demo on that site above) by the path:
Folder 2 > Folder 2.1 > Folder 3.1.1 > SubItem 3.1.1.1
When I click on the SubItem 3.1.1.1
I want that the all previous items (from the path above) changes their backgrounds. The code below selects only the top-most item. How to fix that ?
$('#nav > li').click(function () {
$(this).children('a').css('background-color', 'red');
$(this).parents('ul').each(function () { $(this).prev('a').css('background-color', 'red'); });
});
. In that scenario, my code fails.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…