1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Jquery menus

Discussion in 'General PHP and MySQL Discussions' started by rivacom, Feb 24, 2015.

  1. rivacom

    rivacom Active Member

    I know this forum is php/mysql issues but figured maybe someone can point me in the right direction as jscript isn't my strong suit.

    I'm trying to setup a vertical menu system for my front page. However I seem to be having some issues with it. When the site loads, it loads each div container when there should only be one that switches based on which button is pressed. The kicker is, if you press the menu buttons, the extra div containers disappear and the menus work fine. Here is the JS besides jquery


    http://revenantgaming.com is the site.

    HTML:
    $(function(){
      $('#sidemenu a').on('click', function(e){
        e.preventDefault();
    
        if($(this).hasClass('open')) {
          // do nothing because the link is already open
        } else {
          var oldcontent = $('#sidemenu a.open').attr('href');
          var newcontent = $(this).attr('href');
         
          $(oldcontent).fadeOut('fast', function(){
            $(newcontent).fadeIn().removeClass('hidden');
            $(oldcontent).addClass('hidden');
          });
         
        
          $('#sidemenu a').removeClass('open');
          $(this).addClass('open');
        }
      });
    });
    Can provide other code as well.
     
  2. rivacom

    rivacom Active Member

    Disregard, not sure if theres a better way, but I just used a counter and some CSS to hide anything after the first array record. Works perfect.
     

Share This Page