jQuery help needed

Thanks guys. The problem is that this is a type of SharePoint control that I have no control over what is rendered.

All I have to go on is the selected li element. I had thought I could maybe hide all items to begin with and then show only the path to the selected node but I'm not sure how to do this without knowing the number of nested elements.

Edit: trip that code works for the level shown in my markup in JSFiddle but it doesn't work correctly for other levels in the navigation.
 
Last edited:
Got it sorted last night. Thanks for the pointers.

Code:
$(document).ready(function($) {
   $(function() {
       $(".s4-ql ul.root ul li").hide();
       $("li.selected").parents("li").andSelf().each(function(index,elem) {
       $(this).siblings().andSelf().show();
    });
    $("li.selected").children("ul").children("li").show();
  });
});
 
Just FYI, you've got two document ready handlers there, you can cut out the first one:

Code:
$(function() {
    $(".s4-ql ul.root ul li").hide();
    $("li.selected").parents("li").andSelf().each(function(index,elem) {
        $(this).siblings().andSelf().show();
    });
    $("li.selected").children("ul").children("li").show();
});

Do I not need the ready function?
 
Back
Top Bottom