I have a menu that when you click on a button it slides down a set of
options pertaining to that click, and when you click on another one
the one open slides out and the new one slides in. I can get this to
work but there are about 15 menus, so writing the code 15 times for 15
buttons begins to add up in file size and slows down the smoothness of
the code. I am trying to write a script that adds a variable to the
menu and tells it to scroll up all menus when the button is clicked,
excluding the menu that is currently open since that is set to a
toggle.

Here is my code where I'm telling it to ignore menu1 and menu2 and
only scroll up menu3 and up. I also set it so it only slides them up
if they are visible so there are no jumps in the animation. I know I
will have to use this for each separate button, but the lines of code
will be much lighter with 6 lines of code per button instead of almost
20. If anyone knows what I'm missing in this code, or maybe a code
that will work if this is completely wrong please let me know. Thanks
in advance!

for(w=0;w<100;w++) {
        $("#menu" +w).hide();
        if (w > 2) {
                $("#Btn2").click(function () {
                        $("#menu2").toggle("slide", { direction: "up" }, 300);
                        $("#menu" +w).is(':visible').hide("slide", { direction: 
"up" },
300);
                });
        }
}

Reply via email to