Jquery Countup Timer

白昼怎懂夜的黑 提交于 2019-12-21 06:05:13

问题


I was trying to achieve count up timer with this jquery plugin.

As I am newbie on this, I really don't understand their documentation.

What I want to display is. I want to display counter which counts from 1st January 2005 till current date. Example of output display is

5 years 5months 5hours 5seconds (seconds will be keep counting)

Please kindly help me by posting snippets to achieve. Thanks for your time and greatly appreciated.


回答1:


try:

var sinceYear = new Date('01/01/2005');
$('#defaultCountdown').countdown({since: sinceYear});​

quick demo

edit more options

var sinceYear = new Date('01/01/2005');
$('#defaultCountdown').countdown({since: sinceYear,
                                  format: 'YdHMS',
                                  layout:'<b>{yn} {yl},{dn} {dl} and '+ 
                                       '{hn} {hl}, {mn} {ml}, {sn} {sl}</b>'});​

another quick demo




回答2:


$('#since').countdown({ since: new Date(2005, 1 - 1, 1) });

You're looking for since.




回答3:


<html>
  <head>
    <title>Sample Page</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <style type="text/css">@import "jquery.countdown.css";</style> 
    <script type="text/javascript" src="jquery.countdown.js"></script>
    <script type="text/javascript">
      var epoch = new Date("1/1/2005");
      $(document).ready(function(){
        $("#countup").countdown({since: epoch});
      });
    </script>
  </head>
  <body>
    <div id="countup">

    </div>
  </body>
</html>

code untested. you will need to accommodate the location of the script files yourself.




回答4:


Edited:

<script type="text/javascript">
    $('#defaultCountdown').countdown({ since: new Date(2005, 0, 1) }); 
</script>

<span id="defaultCountdown" class="countdown"></span>


来源:https://stackoverflow.com/questions/2778408/jquery-countup-timer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!