0

我在网上找到了一个 jQuery 时钟(它很棒,你应该抓住它!)但我想显示时间而不必从下拉列表中选择(参见示例:http ://www.robertmeans.com/clock )。我对 jQuery 一无所知。我该如何修改这个时钟,使其只显示时间而无需进行选择?我希望能够放置我想要的任何 UTC 偏移量并在那个时间打印时钟。

<html>
  <head>
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js</script>
  <script type="text/javascript" src="scripts/jclock.js"></script>
  <link rel="stylesheet" href="css/homepage.css" />
  <script type="text/javascript">
    $(document).ready(
    function() {
       $("#zones_Australia").change(function(){
       if ($('#time-cont .time').length>0){ $('#time-cont .time').remove();}
   var offset = $(this).val();    
       if (offset == '') return;       

   $('#time-cont').append('<div class="time"></div>');

       var options = {
        format:'<span class=\"dt\">%a, %d %b %H:%M:%S</span>',
        timeNotation: '12h',
        am_pm: true,
        utc:true,
        utc_offset: offset
      }

      $('#time-cont .time').jclock(options);
   });
 });
</script>

  </head>
  <body>
   <select id="zones_Australia">
    <option value="">--Select--</option>
    <option value="-7">US Pacific</option>
  </select>
  </body>
</html>
4

1 回答 1

0

I think this should work:

     $(document).ready(
        function() {

           if ($('#time-cont .time').length>0){ $('#time-cont .time').remove();}
//set the offset here       
var offset = -7;    
           if (offset == '') return;       

       $('#time-cont').append('<div class="time"></div>');

           var options = {
            format:'<span class=\"dt\">%a, %d %b %H:%M:%S</span>',
            timeNotation: '12h',
            am_pm: true,
            utc:true,
            utc_offset: offset
          }

          $('#time-cont .time').jclock(options);
     });
于 2013-04-20T01:19:34.643 回答