I have some JQuery code where an if-then statement is being run after a .slideToggle event. I just don't understand why the if section is still being run when it would appear the if statement is false. Code incoming:
JQuery:
$(function() {
var pull = $('#pull');
menu = $('div#nav ul');
menuHeight = menu.height();
head = $('div#welcome');
down = true;
$(pull).on('click', function(e) {
e.preventDefault();
menu.slideToggle(function(){
if(down = true){
$(head).animate({paddingTop:'287px'}, {duration: 0, queue: false});
down = false;
}
else{
$(head).animate({paddingTop:'125px'}, {duration: 0, queue: false});
down = true;
}
});
After the .slideToggle event runs once it seems to work fine, but run it again and it just runs the first line again. I even used .consoleLog() to make sure that "down = false". So it seems to just keep running the if statement and I don't understand why