I have a menu button on my website, it opens a menu bar with options. When you click on one of the options it opens a new div below with a PDF containing information. Everything works, but I have one main problem. When I click on a new link, the old link doesn't go away. My links keep stacking on top of each other and I have to click on all of them again in order to make the new divs go away.
I was looking into a switch statement to maybe solve this. Like if a user clicks on a menu option, the menu option opens and then if they click on another menu options the old menu options closes and the new ones opens.
here is my code so far,
$(document).ready(function() {
$( "#mainMenu" ).click(function() {
$( "#flexMenu" ).toggle("slow");
});
/*If mainMenu closes, close all over menus*/
/*if dinnerButton is pressed, close any other menus open besides mainMenu
than open dinner menu*/
$( "#dinnerButton" ).click(function() {
$( "#menuDropDinner" ).toggle("slow");
});
$( "#lunchButton" ).click(function() {
$( "#menuDropLunch" ).toggle("slow");
});
$( "#wineButton" ).click(function() {
$( "#menuDropWine" ).toggle("slow");
});
$( "#dolciButton" ).click(function() {
$( "#menuDropDolci" ).toggle("slow");
});
});
Would a series of if else statement be easier then a possible switch statement?
Aucun commentaire:
Enregistrer un commentaire