【发布时间】:2020-10-20 07:17:30
【问题描述】:
我正在自己做一些练习。我已经创建了这个由这个函数更新的简单页面
function today(){
hoje = Date();
switch (hoje.slice(0,3)) {
case 'Mon' :
todayIs = 'Monday';
break;
case 'Tue' :
todayIs = 'Tuesday';
break;
case 'Wed' :
todayIs = 'Wednesday';
break;
case 'Thu' :
todayIs = 'Thursday';
break;
case 'Fri' :
todayIs = 'Friday';
break;
case 'Sat' :
todayIs = 'Saturday';
break;
case 'Sun' :
todayIs = 'Sunday';
break
}
todayInFunction = new Date;
hours = todayInFunction.getHours();
if (hours < 10 && hours < 12){
hours = `0${hours} AM`;
} else{
hours = hours + 'PM';
}
minutes = todayInFunction.getMinutes();
minutes < 10 ? minutes = '0' + minutes : false;
seconds = todayInFunction.getSeconds();
seconds < 10 ? seconds = '0' + seconds : false;
console.log(`Current time is: ${hours} : ${minutes} : ${seconds}`);
printHere = document.getElementById("print-here");
printHere.innerHTML = `Today is ${todayIs} <br> Current time is: ${hours} : ${minutes} : ${seconds}`;
}
setInterval(
() => {
today()
}, 1000
)
【问题讨论】:
-
能否提供您当前的 HTML 和 CSS?
标签: javascript css shake