Blosom
Blosom

Reputation: 111

Simple jQuery animation should run every time I click, not only one time

Like in the ropie, I would like to have simple jQuery animation running while every click, not only first time. And also when we click again in order to close menu this should show opacity 0 with the same animation. The toggle doesn't work.

$(document).ready(function () {
  $('#menu-open').click(function () {
    $(this).toggleClass('open');
    $('nav').toggleClass('visible').animate({opacity: '1.0'}, 400);
  });
});

Upvotes: 1

Views: 90

Answers (1)

Kalvisan
Kalvisan

Reputation: 33

You can try using JQuery fadeToggle function: http://api.jquery.com/fadetoggle/

So your code will look like this:

$(document).ready(function () {
    $('#menu-open').click(function () {
       $(this).toggleClass('open');
       $('nav').fadeToggle();
    });
});

Upvotes: 1

Related Questions