Hi, I am trying to use jQuery to hide some items in a list to only show the trail of the selected node.
See this JSFiddle for the markup:
http://jsfiddle.net/QLbAS/4/
See this JSFiddle for the markup:
http://jsfiddle.net/QLbAS/4/
$(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();
});
});
$(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(); });
You need only one, but this:Do I not need the ready function?
$(document).ready(function() { });
$(function() { });
haha, no worries.Sorry Mr Trip, just saw you posted the same thing