我正在尝试使用以下示例:http://www.techtricky.com/jquery-code-to-show-time-in-different-countries/
然而,我对JS并不熟悉,而且遇到了麻烦。我基本上是想让它显示的时间,没有选择框。
然后,我将尝试在一次显示多个不同的时间。
例如:
+
我意识到var选项允许我设置样式和时间偏移。然而,功能是我有点困惑。我一直在尝试将#区域设置为自动运行,但在没有选择的情况下无法实现。(理想情况下,我根本没有选择,我尝试设置一个默认的区域选择,但这也不起作用),我认为这是因为函数有$("#zones").change,所以只能在更改时运行。
蒂娅!
发布于 2013-01-11 17:24:31
您可以这样做,很明显,您可以在循环中这样做,这样您就不必像我这样编写代码3次了。
另外,jclock文档中很少有示例:https://sites.google.com/site/jqueryjclockjs/。
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://techtricky.com/wp-content/jquery/jquery.jclock.js"></script>
<script type="text/javascript">
$(document).ready(
function() {
$('#time-cont1').append('<div class="time"></div>');
var options = {
format:'<span class=\"dt\">%A, %d %B %I:%M:%S %P</span>',
timeNotation: '12h',
am_pm: true,
fontFamily: 'Verdana, Times New Roman',
fontSize: '20px',
foreground: 'black',
background: 'yellow',
utc:true,
utc_offset: 8
}
$('#time-cont1 .time').jclock(options);
$('#time-cont2').append('<div class="time"></div>');
var options = {
format:'<span class=\"dt\">%A, %d %B %I:%M:%S %P</span>',
timeNotation: '12h',
am_pm: true,
fontFamily: 'Verdana, Times New Roman',
fontSize: '20px',
foreground: 'black',
background: 'yellow',
utc:true,
utc_offset: 6
}
$('#time-cont2 .time').jclock(options);
$('#time-cont3').append('<div class="time"></div>');
var options = {
format:'<span class=\"dt\">%A, %d %B %I:%M:%S %P</span>',
timeNotation: '12h',
am_pm: true,
fontFamily: 'Verdana, Times New Roman',
fontSize: '20px',
foreground: 'black',
background: 'yellow',
utc:true,
utc_offset: -5
}
$('#time-cont3 .time').jclock(options);
});
</script>
</head>
<body>
Country1: <div id="time-cont1"></div>
Country2: <div id="time-cont2"></div>
Country3: <div id="time-cont3"></div>
</body>
</html>发布于 2013-01-11 19:44:21
您可能会对此感兴趣:拉斐尔极地钟
https://stackoverflow.com/questions/14283234
复制相似问题