0

嗨,我试图让我的菜单在选择项目时保持打开状态,而不是立即关闭。这是我的 jquery.collaspe.js 文件:

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();

 });

};

我正在使用无序列表,当有人单击列表项时,菜单会再次关闭,而不是让用户知道它已被选中并在列表中的该项目上保持打开状态.....

我知道我需要添加某种“选定”代码,但不确定如何执行此操作。请帮忙!!!!!!!

4

1 回答 1

0
  1. 将 CSS 类添加到所选项目
  2. 当新页面打开时:使用其类获取菜单项并显示菜单(可能通过调用.show()其父项)
于 2010-11-23T19:49:20.450 回答