A
A
Alexander Plyusnin2018-08-12 13:07:06
css
Alexander Plyusnin, 2018-08-12 13:07:06

Why don't the class styles change when the hamburger button is clicked?

Hello, please tell me why styles are not substituted when clicking on the hamburger button? That is, in html, the .top-nav-menu-active style is substituted, and visibility remains display: none

<script>
      $(document).ready(function() {
        var menuBtn = $('.top-nav-menu-btn');
        var topMenu = $('.menu');

        menuBtn.on('click', function(event) {
          event.preventDefault();
          topMenu.toggleClass('top-nav-menu-active');
        })
      })
    </script>

.menu {
  display: none;
}

.menu .top-nav-menu-active {
  display: block;
}

.top-nav-menu-btn {
  width: 40px;
  height: 40px;
  border: none;
  color: #fff;
  background:#6ec256;
  position: fixed;
  top: 15px;
  right: 10px;
  font-size: 18px;
  cursor: pointer;
  display: block;

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dev-rob, 2018-08-12
@bioWeb

.menu .top-nav-menu-activein your case the selector should be merged .menu.top-nav-menu-active
CSS selectors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question