Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 要放置时间计时器吗_Javascript_Jquery - Fatal编程技术网

Javascript 要放置时间计时器吗

Javascript 要放置时间计时器吗,javascript,jquery,Javascript,Jquery,我想附加一个基于CT下午4点的计时器,请任何具有JQuery/JavaScript知识的人帮助我 var now = new Date();//get local time var hrs = 16-(now.getUTCHours()-5);// convert local to UTC and then CST and checks time differnce with 4CT var min = 60-now.getUTCMinutes(); 使用setInterval Javasc

我想附加一个基于CT下午4点的计时器,请任何具有JQuery/JavaScript知识的人帮助我

var now = new Date();//get local time
var hrs = 16-(now.getUTCHours()-5);// convert local to UTC and then CST and checks time differnce with 4CT
var min = 60-now.getUTCMinutes();

使用
setInterval

Javascript

//ticker function that will refresh our display every second
function tick() {
    var now = new Date(); //get local time
    var hrs = 16 - (now.getUTCHours() -5); // convert local to UTC and then CST and checks time differnce with 4CT
    var min = 60 - now.getUTCMinutes();
    var sec = 60 - now.getUTCSeconds();
    if (min > 0) {
        hrs = hrs - 1;
    }
    document.getElementById('time_ticker').innerHTML = hrs + ':' + min + ':' + sec;
}


//the runner
var t = setInterval(tick, 1000);
HTML


供货情况:库存
如果在CT下午4点之前订购,则当天发货

我添加了秒数,以使股票代码看起来更生动。

请您检查一下这把小提琴,并告诉我我到底出了什么问题,我想替换这条消息。检查这里的fiddel,您需要:1。您需要jquery2。选择onDomready 3。使用jquery.html()而不是Javascript.innerHTML()4。要更新内部HTML,请使用.HTML(“…”)5。在末尾添加一个花括号
<div id="primaryProductAvailability">
    <div class="short-message-block">   <span>Availability: </span><span class="message availability in-stock">In Stock</span>

    </div>
    <div class="long-message-block">    <span class="message in-stock">Ships same day if ordered before 4pm CT</span>

    </div>
</div>
<span id="time_ticker"></span>