V
V
Vitya Podpriklopolny2018-02-16 18:07:17
JavaScript
Vitya Podpriklopolny, 2018-02-16 18:07:17

How to set menu animation in jquery?

$('.icon-burger').click(function(){
  $('.icon-burger').toggleClass('burger-active');
  $('.header-container').toggleClass('header-container-active');
  $('.menu').toggleClass('menu-active');
});

how to make ul with class menu appear smoothly when icon-burger is clicked.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Chuprik, 2018-02-16
@choupa

$('.icon-burger').click(function(){
  $('.icon-burger, .header-container, .menu').fadeToggle();
  ...
});

But kosher, it seems to me, is to solve with CSS and not with jQuery animation
$('.icon-burger').click(function(){
  $('.icon-burger, .header-container, .menu').toggleClass('active');
});

.icon-burger, .header-container, .menu {
   opacity: 0%;
   transition: 1s;
}

.active {
   opacity: 100%;
   transition: 1s;
}

But when loading the page, you will need to disable the transition. This is a separate story, I do not write here.

S
Stimulate, 2018-02-16
@Stimulate

https://www.w3schools.com/jquery/jquery_fade.asp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question