title: Show div once per visit, also dissapear after 5 seconds
body: <p>I want to show a div once per user session (it shows only on the fronpage for example, and then when you open subpages, it doesn't show) then hide it after 5 seconds.</p>
  
  <p>Here's what I have so far. My problem is that on first load of the page, it dissapears, as it should and then every load after that, it does not.</p>
  
  <p>html:</p>
  
  <pre><code>&lt;a id="swipe-tooltip"&gt;Swipe Tooltip&lt;/a&gt;
  </code></pre>
  
  <p>js:</p>
  
  <pre><code>$( document ).ready(function() {
      if ( !localStorage.getItem("visited") ) {
          $("#swipe-tooltip").show().fadeIn();
          $("#swipe-tooltip").show().delay(5000).fadeOut();
  
          localStorage.setItem("visited", true);
      }
  
      window.addEventListener("beforeunload", function( event ) {
          localStorage.setItem("visited", false);
      });
  });
  </code></pre>