title: How to combine 2 javascript codes in one?
body: <p>I have somehow assembled 2 single codes (absolute beginner) and try to combine the two code blocks in one. </p>
  
  <p>I tried the following: As soon as I scroll down, the navigation should be hidden and when I scroll up, it should appear again. </p>
  
  <p>Additional: As soon as you move the mouse over it (.nav-visibility), the navigation should appear again and disappear again when mouseout. -> but only if you have scrolled down!</p>
  
  <p>Problem: When you're scrolling down, the navigation disappears = which is great. But as soon as you scroll up again, it doesn't appear anymore.</p>
  
  <pre><code>var zero = 0;
  $(document).ready(function() {
    $(window).on('scroll', function() {
      $('.nav-visibility').css("opacity", "0", $(window).scrollTop() &gt;
        zero);
      zero = $(window).scrollTop();
    })
  })
  </code></pre>
  
  <pre><code>$('nav').mouseover(function() {
    $('.nav-visibility').css("opacity", "1");
    $('.nav-visibility').css("visibility", "visible");
  });
  
  $('nav').mouseout(function() {
    $('.nav-visibility').css("opacity", "0");
    $('.nav-visibility').css("visibility", "hidden");
  });
  </code></pre>