开发者

Jquery Collapser Menu Needs to stay open when a new page loads

Hi I am trying to make my menu stay open when an item is selected instead of closing back up right away. Here is my jquery.collaspe.js file:

jQuery.fn.not_exists = function(){return jQuery(this).length==0;}

jQuery.fn.jqcollapse = function(o) {

 // Defaults
 var o = jQuery.extend( {
   slide: true,
   speed: 300,
   easing: ''
 },o);

 $(this).each(function(){

  var e = $(this).attr('id');

  $('#'+e+' li > ul').each(function(i) {
     var parent_li = $(this).parent('li');
     var sub_ul = $(this).remove();

     // Create 'a' tag for parent if DNE

     if (parent_li.children('a').not_exists()) {
      parent_li.wrapInner('<a/>');
     }

     parent_li.find('a').addClass('jqcNode').css('cursor','pointer').click(function() {
         if(o.slide==true){
          sub_ul.slideToggle(o.speed, o.easing);
         }else{
          sub_ul.toggle();
         }
     });
     parent_li.append(sub_ul);
 });

 //Hide all sub-lists
  $('#'+e+' ul').hide();

 });

};

I am using unordered lists & when someone clicks on a list item the menu closes right back up again instead of letting the us开发者_开发问答er know it has been selected and stay open on that item in the list.....

I know I need to add some sort of "selected" code but not sure how to do this. Please help!!!!!!!


  1. Add a CSS class to the selected item
  2. When a new page opens: get the menu item using its class and display the menu(probably by calling .show() on its parents)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜