User:Amit6/sandbox14.js

  $(document).ready(function{

//Store Image paths var toggleMinus = 'path/to/minus/image'; var togglePlus = 'path/to/plus/image';

var $subHead = $('.children').parent;

//Add the Plus image to every child by default $subHead.prepend(' ');

//By Default put the Menu in collapsed state $('.children').parent.children('ul').slideUp('fast');

//Expand All Code $('.expand').click(function {		$subHead.children('ul').slideDown('fast');		$('img', $subHead).attr('src', toggleMinus); });

//Contract All Code $('.contract').click(function {		$subHead.attr('src', toggleMinus).children('ul').slideUp('fast');		$('img', $subHead).attr('src', togglePlus); });

//Expand or Contract one particular Nested ul $('img', $subHead).addClass('clickable').click(function { var toggleSrc = $(this).attr('src'); if ( toggleSrc == toggleMinus ) { $(this).attr('src', togglePlus).parent.children('ul').slideUp('fast'); } else{ $(this).attr('src', toggleMinus).parent.children('ul').slideDown('fast'); }; }); });