我在网站上使用Flipclock,我的问题是...如何在页面中放置超过1个Flipclock?
如果我尝试复制它们,则不起作用(如在复制中粘贴div标签,然后将其重命名)
知道如何在网页中放置超过1个时钟吗?
http://flipclockjs.com/
这就是我得到的:
http://i58.tinypic.com/k3xk0p.png
这是我的代码:
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link rel="stylesheet" href="../includes/flipclock.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="../includes/flipclock.js"></script>
<script type="text/javascript">
var clock;
$(document).ready(function () {
var clock;
clock = $('.clock').FlipClock({
clockFace: 'DailyCounter',
autoStart: false,
callbacks: {
stop: function () {
$('.message').html('The clock has stopped!')
}
}
});
clock.setTime(65000); /*60 = 1 Minute*/
clock.setCountdown(true);
clock.start();
});
</script>
<style type="text/css">
section
{
background-color:rgba(0, 0, 0, 0.45);
width:900px;
padding-top:5px;
margin-left:10px;
border:1px solid rgb(16, 16, 16);
}
footer
{
position:relative;
top:25px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
<div class="clock" style="margin:2em;"></div>
<div class="message"></div>
<div class="clock" style="margin:2em;"></div>
<div class="message"></div>
</asp:Content>
最佳答案
初始化FlipClock的新实例,也许就可以解决问题。并选择不同的类名称:
<div class="clockTwo" style="margin:2em;"></div>
和JS:
clockTwo = $('.clockTwo').FlipClock({
clockFace: 'DailyCounter',
autoStart: false,
callbacks: {
stop: function () {
$('.message').html('The clock has stopped!')
}
}
});