//获取当前时间并拼接放到div中的函数
function nowTime(){
var nowDate = new Date();
var year = nowDate.getFullYear();
var month = nowDate.getMonth()+1;
month = month>9 ? month : "0" + month;
var date = nowDate.getDate();
date = date>9 ? date : "0" + date;
var hour = nowDate.getHours();
hour = hour>9 ? hour : "0" + hour;
var miunte = nowDate.getMinutes();
miunte = miunte>9 ? miunte : "0" + miunte;
var second = nowDate.getSeconds();
second = second>9 ? second : "0" + second;
$("#showTime").text(year+"年"+month+"月"+date+"日"+hour+"时"+miunte+"分"+second+"秒");
}
html页 <div class="header-item" id="showTime" style="white-space: nowrap"></div>js代码//获取当前时间并拼接放到div中的函数 function nowTime(){ var nowDate = new Date(); var year = now...