[問題][js] 一段顯示時間的code
以下是code部份
不知為什麼 跑不出結果
用 alert(timer)去看會顯示 null(在firefox下)
為什麼呢??????? orz//////
(function() {
var self = this;
var now,hours,minutes,seconds,timeValue;
var timer = document.getElementById('tmr');
this.init = function() {
setInterval("self.update()", 1);
};
this.update = function() {
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
timeValue = (hours >= 12) ? "下午 " : "上午 ";
timeValue += ((hours > 12) ? hours - 12 : hours) + " 點";
timeValue += ((minutes < 10) ? " 0" : " ") + minutes + " 分";
timeValue += ((seconds < 10) ? " 0" : " ") + seconds + " 秒";
timer.value = timeValue;
};
this.init();
})();
document.write('<div id="righttime"><input type="text" id="tmr" style="
width: 190px; border-width:0px; margin: 0 auto; font-size: 20px;
background-color: blue; vertical-align: middle; color: white;" /></div>');
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.95.110
→
06/10 01:01, , 1F
06/10 01:01, 1F
→
06/10 01:01, , 2F
06/10 01:01, 2F
※ 編輯: kevintwo 來自: 140.113.95.110 (06/10 01:02)
※ 編輯: kevintwo 來自: 140.113.95.110 (06/10 01:03)
→
06/10 11:05, , 3F
06/10 11:05, 3F
→
06/10 19:33, , 4F
06/10 19:33, 4F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章