开发者

jQuery Accordion and active link

开发者 https://www.devze.com 2022-12-08 21:02 出处:网络
i use the followig accordion menu: function initMenu() { $(\'#submenu ul\').hide(); //$(\'#submenu ul:first\').show();

i use the followig accordion menu:

function initMenu() {
  $('#submenu ul').hide();
  //$('#submenu ul:first').show();
  $('#submenu li a').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        }
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
 开发者_Go百科       $('#submenu ul:visible').slideUp('normal');
        checkElement.slideDown('normal');
        return false;
        }
      }
    );
  }
$(document).ready(function() { initMenu(); });

now, when a link in the #submenu list gets active, the accordion closes and i have to open it up again when chooseing another link from the #submenu. my question: how can i tell this script, that when a li in the #submenu list has the class .active_link, the accordion opens automatically that current ul #submenu list?

the .active_link class is only set, when the link is active!

you understand my question? :)

thanks and regards!


Try triggering a click on it when the dom is ready:

$('#submenu li a.active_link').click();
0

精彩评论

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

关注公众号