如何从 jquery 倒计时获取等待时间
我是jquery新手,我设置了一个倒计时时间。下面是一个问题和答案。我想得到用户选择答案时的剩余时间,我该怎么做?谢谢 PS:我搜索了一下,发现了一个叫curvyCorners的东西,据说比较容易得到剩余时间,但我不知道
$(function() {
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
$('#defaultCountdown').countdown({
until: +30,
compact: true,
format: 'MS'
});
$('#getNow').click(function() {
var periods = $('#curvyCorners').countdown('getTimes');
var text = '';
for (var i = 0; i < periods.length; i++) {
text += periods[i] + '' + $.countdown.regional[''].labels[i] + '';
}
$('#curPeriods').text(text);
});
$('#removeCountdown').toggle(function() {
$(this).text('Re-attach');
$('#defaultCountdown').countdown('destroy');
},
function () {
$(this).text('Remove');
$('#defaultCountdown').countdown({
until: +30
});
}
);
});
I'm new in jquery and I set a countdown time. Below that it is a question and answers.I want get the left time when user choose the answer,how can I do that?Thanks
PS:I searched and found something called curvyCorners which said to be easier to get the left time ,but I don't know that
$(function() {
var newYear = new Date();
newYear = new Date(newYear.getFullYear() + 1, 1 - 1, 1);
$('#defaultCountdown').countdown({
until: +30,
compact: true,
format: 'MS'
});
$('#getNow').click(function() {
var periods = $('#curvyCorners').countdown('getTimes');
var text = '';
for (var i = 0; i < periods.length; i++) {
text += periods[i] + '' + $.countdown.regional[''].labels[i] + '';
}
$('#curPeriods').text(text);
});
$('#removeCountdown').toggle(function() {
$(this).text('Re-attach');
$('#defaultCountdown').countdown('destroy');
},
function () {
$(this).text('Remove');
$('#defaultCountdown').countdown({
until: +30
});
}
);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下方法:
它将返回一个 number[7] 数组,其中条目为年、月、周、日、小时、分钟和秒。
You can use the following method:
It will return a number[7] array which entries are years, months, weeks, days, hours, minutes and seconds.