2013-04-20 69 views
0

我發現了一個jQuery時鐘在線(這很棒,你應該抓住它!),但我想顯示的時間,而不必從下拉列表中選擇(見例如:http://www.robertmeans.com/clock)。我對jQuery一無所知。我該如何去修改這個時鐘,這樣它就可以顯示時間而不必做出選擇?我希望能夠把我想要的任何UTC抵消時間,並打印時鐘。刪除從麻省理工學院jQuery時鐘的下拉選擇器

<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> 

回答

0

我認爲這應該工作:

 $(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); 
    }); 
+0

天才!就這樣,我又回到工作了!謝謝你一百萬次! – LyleCrumbstorm 2013-04-20 01:24:44

+0

@ user2178146如果解決了您的問題,請接受答案。 – 2013-04-20 01:28:10

相關問題