I’m new to jquery and i’m trying to use the .slidedown function on a drop down menu. I want the menu to open when clicked and close when option or menu is clicked again. However when the menu is clicked as it is, it simply bounces open and closed rather than staying open. Here is the code:
*(function($) {
/* $('#drop').click(function() {
if (paneldown == false) {
$('#ddd').slideUp(5000);
paneldown = false;
}
if(paneldown != false) {
$('#ddd').slideDown(5000);
paneldown = true;
}
});
*/
var paneldown = false;
$('#drop').click(function() {
if(paneldown == false) { $('#ddd').slideDown(500); paneldown = true; }
if(paneldown == true) { $('#ddd').slideUp(500); paneldown = false;}
//$('#ddd').toggle(5000), (function() {
// });
});
})(jQuery);
// JavaScript Document*
If you would still like to use the if statment then do this:
It wont work if you try using two ifs but I dont recommend using ifs for something like this.
use: