I have a top navBar that I need to go up when I click it.
var foo = false
$(document).ready(function(){
$(".topBar").click(function(){
findOut();
});
});
function up()
{
$(".topBar").animate({height:5},"slow");
}
function down()
{
$(".topBar").animate({height:30},"slow");
}
function findOut()
{
if (foo===true)
{
down();
up = false;
}
elseif (foo===false)
{
up();
up = true;
}
}
And before you ask, yes I do have the jQuery file installed.
Here is my website: learntc.net The very top bar.
Have you consider doing:
that will make your bar go up or down without the need to use a flag.
docs
If you don’t want to slide it all the way, your code looks fine except for a missing whitespace in
elseif(up===false).If you try it on your site you’ll see that the text is still visible even when you set the height to 5px, I recommend you add a
overflow:hiddenso it can remain hiddenEDIT
Working code: