重新加载功能,而不是页面:Javascript

时间:2017-04-20 22:56:25

标签: javascript jquery

<!DOCTYPEhtml>
 <head>

  <center><p id="final"></p></center>


  <script>
  var currentDay = new Date();
  var breakStart = new Date(2017, 3, 21, 15, 20);
  var breakEnd = new Date(2017, 4, 1, 8, 40);
  var difference = (breakStart.getTime() - currentDay.getTime())/1000;


days = Math.floor(difference / 86400)
difference %= 86400;
hours = Math.floor(difference / 3600)
difference %= 3600;
minutes = Math.floor(difference / 60)
difference %= 60;
seconds = Math.floor(difference / 1)
difference %= 1;

function refresh(){
  document.getElementById("final").innerHTML = ("There are " + days + " days, " + hours + " hours, " + minutes + " minutes, and " + seconds + " seconds left until spring break.")
  refresh();
  }
    setTimeout(function(){
       window.location.reload(1);
     }, 951);

  </script>

我为课程编写的这个程序让你知道什么时候春假会开始。我已经广泛寻找解决问题的方法。我的问题是我需要重新加载函数&#34; refresh()&#34;而不是整个页面。即便是我疯狂的编码伙伴也无法弄明白。如果你删除它的功能。我只是把函数放在那里试图找到一种方法来刷新它。

一切有帮助, 谢谢!

0 个答案:

没有答案