JS Countdown与jQuery 1.10.2不兼容
问题描述:
因此,我的倒计时脚本出于某种原因与我的代码不兼容。 我试着让它每天都在特定的时间倒计时,但是我的网上商店只能使用jquery 1.x和所有其他插件,所以没有其他的jquery版本可以使用。 https://jsfiddle.net/nskhbL12/JS Countdown与jQuery 1.10.2不兼容
<script>
window.onload = date;
function ShowTime() {
var now = new Date();
var hrs = 20-now.getHours();
var mins = 60-now.getMinutes();
var secs = 60-now.getSeconds();
timeLeft = "" +hrs+' t : '+mins+' m : '+secs+' s';
$("#countdown").html(timeLeft);
}
var countdown;
function StopTime() {
clearInterval(countdown);
}
setInterval(ShowTime ,1000);
</script>
<span id="date">Order before <span id="countdown"></span> and receive your package tomorrow!</span>
答
尝试用
jQuery(function($) {
setInterval(ShowTime ,1000);
});
或者使用类似
$ = jQuery;
似乎工作:https://jsfiddle.net/eauksku8/ –
我要投票关闭这个问题作为脱离主题,因为jQuery没有涉及。 –
@ uom-pgregorio你正在使用v1.9.1。 Toni jQuery用于在'#countdown'内写入HTML文本。 – Grork