jQuery手风琴亮点

时间:2014-05-09 21:10:34

标签: jquery sharepoint-2013 sharepoint-online

为什么此代码将默认设置为突出显示最后一项?

/* left quick launch */
$(function(){
 /*set dynamic css logic*/
 if($('#sideNavBox .menu-item.selected').length){
  //propagates the selected class, up the three.
  $('li.static').removeClass('selected');
  $('#sideNavBox .menu-item.selected').parents('li.static').addClass('selected');

  //collapses top siblings of selected branch
  $('#sideNavBox .menu-item.selected').parents('li.static').last().siblings()
   .find('> ul').hide();
 }
 else $('#sideNavBox .root.static > li.static > ul').hide();

 /*set accordion effect*/
 $('#sideNavBox .root.static > li.static').each(function(){
  if($(this).find('ul').length){
   $(this).addClass('father').find("> a.static.menu-item").click(function(){
  // alert("click");
     if($(this).closest("li").children('ul').css('display') != 'none'){
     //alert("not none");
     $(this).closest("li").removeClass('selected').children('ul').slideUp();   
    }
    else {
     /*collapse-siblings*/
     /*expand*/
         // alert("none");
     $(this).closest("li").addClass('selected').children('ul').slideDown();
     $(this).closest("li").siblings().removeClass('selected').children('ul').slideUp();   

    }
    return false;
   /* return false; *///**<= add this one**
   });
  }
 });

})

0 个答案:

没有答案