I want to have some sort of menu pop-out of the left side of the screen by clicking a button (which is quite easy because I managed to do that) but I also want to be able to make that same menu go back to where it came from when I click the same button.
I think it's the same principle as a collapsible section and I found easy ways to implement one using Bootstrap but I couldn't make it exactly like I wanted it so I figured I'll make it myself using jQuery.
In my code the first click works and the menu pops out, but the second click is supposed to make it go away but doesn't work for some reason. modalWindow is the the menu that's supposed to pop out and hamburger being the button.
What is it that I am missing?
var modalRight = $('.modalwindow').css('right');
$('.hamburger').click(function() {
if (modalRight === '900px') {
$('.modalwindow').animate({
'right': '300px'
}, 200);
$('.image').css('opacity', '50%')
} else {
$('.modalwindow').animate({
'right': '900px'
}, 200);
$('.image').css('opacity', '100%')
};
Aucun commentaire:
Enregistrer un commentaire