title: Updating time span with jquery
body: <p>I have a tiny script which should update a span with the current time. </p>
  
  <p>This script works BEFORE the setInterval but not during the setInterval.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;?= date("d/m/Y") ?&gt; &lt;span id="time"&gt;&lt;/span&gt;
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>$(document).ready(function(){
      var dt = new Date();
      var time = dt.getHours() + ":" + dt.getMinutes();
      $("#time").text(time);
      setInterval(function(){
          console.log("interval");
          time = dt.getHours() + ":" + dt.getMinutes();
          $("#time").text(time);
      },5000);
  });    
  </code></pre>
  
  <p>The span with id time just doesn't change the time.</p>