Show/cover the menu



  • There's a code where 'open_menu' is a button, and 'header_menu' is a menu. When pressed on the button, the menu must appear, and re-pressure will disappear. But instead, the button itself appears and disappears without a click on it (as animation). Tell me where the mistake is, please.

    $(document).ready(function() {
      $(".open_menu").toggle(function() { 
        $(".header_menu").fadeIn();
        return false;
      },  
      function() { 
        $(".header_menu").fadeOut();
        return false;
      }); 
    }); 
    


  • Intoggle http://api.jquery.com/toggle/ There is no option to use the function toggle(callback, callback), consider this method in greater detail. Right, for example:

    <!DOCTYPE html>
    <html>
    

    <head>
    <title>titile</title>
    <meta charset="utf-8">
    <style>
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
    $(function() {
    $(".open_menu").on('click', function() {
    $(".header_menu").toggle();
    });
    });
    </script>
    </head>

    <body>

    <input type="button" value="Меню" class="open_menu">
    <div class="header_menu">Блок меню</div>

    </body>

    </html>




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2