我是网络开发的新手,我想跟踪员工的工作。因此,每当新任务分配给员工时,经理必须添加他的名字和给定时间。添加时间后,它将从给定时间开始倒计时。并且它将在0上变为红色。我已经看到很多例子但是无法实现它。我必须在javascript的下拉列表中添加项目,但我无法调用它。我必须在列表中添加多名员工。
答案 0 :(得分:1)
使用bootstrap或J查询日期时间选择器,并将该日期提供给以下java脚本。
<p id="timer"></p>
$(document).ready(function () {
// Set the date we're counting down to
var countDownDate = new Date("May 30, 2018 15:16:25").getTime();
// Update the count down every 1 second
var x = setInterval(function () {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 *
60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 *
60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("timer").innerHTML = days + "d " + hours +
"h "
+ minutes + "m " + seconds + "s ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("timer").innerHTML = "EXPIRED";
}
}, 1000);
});