gpt4 book ai didi

jquery倒计时显示日期

转载 作者:行者123 更新时间:2023-12-01 05:42:47 25 4
gpt4 key购买 nike

使用这个 jquery 倒计时脚本 http://keith-wood.name/countdown.html像这样:

 <script type="text/javascript">
$(function () {
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
var tm = new Date(tomorrow.getFullYear(),tomorrow.getMonth(), tomorrow.getDate());
$('#defaultCountdown').countdown({until: tm});
});
</script>

还有这个

<div id="defaultCountdown"></div>

允许我根据电脑时间显示 24 小时倒计时。现在我也想获取其中的日期,但我不想要当前日期,我想要第二天的日期

最佳答案

我不确定你的插件是否允许这种功能,所以你必须自己制作这样的插件:

<style>
#tomorrow{
width: 240px;
height: 45px;
margin-bottom:10px;
}
#tomorrow .countdown-section{
padding-left:5px;
}
</style>
<div id="tomorrow" class="is-countdown">
<span class='countdown-section'><span class='countdown-amount' id='tomorrowDay'></span><span class='countdown-period'>Day</span></span>
<span class='countdown-section'><span class='countdown-amount' id='tomorrowDate'></span><span class='countdown-period'>Date</span></span>
<span class='countdown-section'><span class='countdown-amount' id='tomorrowMonth'></span><span class='countdown-period'>Month</span></span>
</div>
<script>
function setTomorrow(){
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.setHours(0);
tomorrow.setMinutes(0);
tomorrow.setSeconds(0);
tomorrow.setMilliseconds(0);
var timer = (tomorrow - today);
$("#tomorrowDay").text(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][tomorrow.getDay()]);
$("#tomorrowDate").text(tomorrow.getDate());
$("#tomorrowMonth").text(['January','February','','March','April','May','June','July','August','September','October','November','December'][tomorrow.getMonth()]);
setTimeout(function(){ setTomorrow(); }, timer);
}
setTomorrow();
</script>

关于jquery倒计时显示日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29775785/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com