Jquery menus

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.
 
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.
 
Top Bottom