If you click the dropdowns at this site: http://ryanbent.com/ – I want each of those tabs to only OPEN one at a time. If you click one, then close the other.
I understand the thought behind it, i sent a class when you click it, and I am trying to go through each of them, but I cant seem to get it to work. I think its my selectors. My code is below:
function HideMenu(){
//$('.open').stop().animate({'top':'-480px'},500,"linear");
$('.open').slideUp();
$(this).removeClass("open");
$("#fuzz").fadeOut();
}
function checkMenu(){ $('.open').slideUp(); }
$('#contact').toggle(function() {
checkMenu();
$('#contact-pull').show().animate({'top':'-50px'}).addClass("open");
//$('#contact-pull').slideDown();
}, function() {
HideMenu();
$('#contact-pull').animate({'top':'-180px'})
});
$('#about').toggle(function() {
checkMenu();
$('#about-pull').show().animate({'top':'55px'}).addClass("open");
// $('#about-pull').slideDown();
}, function() {
HideMenu();
$('#about-pull').animate({'top':'-465px'})
});
$('#portfolio').toggle(function(){
checkMenu();
$('#portfolio-pull').animate({'top':'75px'}).addClass("open");
}, function() {
HideMenu();
$('#portfolio-pull').animate({'top':'-150px'});
});
Does anyone have any suggestions on how I can get this working? I have been struggling with this and cant seem to get it to work. I set the flag fine, but I need to check for it.
You could take a cleaner approach where you wouldn’t have to init each menu item individually but to just edit your existing code you could try something like this:
The changes I made were:
Hope it helps – I didn’t test it, just corrected the errors that jumped out at me 🙂