Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] jQuery: Menus appear/disappear on click Re: [Solved] jQuery: Menus appear/disappear on click

#72780
rickylamerz
Member
  
1111

2222

3333

4444

Using this markup it’s easily doable.

Do something like:


$(document).ready(function(){
$('.megamenu').css('display','none');
$('ul li a').click(function(){
if($(this).attr('class') != 'displayed'){
$('.megamenu').hide();
$('ul li a').removeClass('displayed');
linkUrl = $(this).attr('href');
linkUrl = linkUrl.replace('#','');

$('#' + linkUrl).css('display','block').animate({opacity:1});
$(this).addClass('displayed');
return false;
}
if($(this).attr('class') == 'displayed'){
linkUrl = $(this).attr('href');
linkUrl = linkUrl.replace('#','');

$('#' + linkUrl).css('display','none').animate({opacity:1});
$(this).removeClass('displayed');
return false;
}
return false;
});
});

I hope this works for you, let me know if your still stuck. :)