javascript 计算器:
系列文章:
js 实现计算器详解及实例代码(一)
javascript 实现计算器时间功能详解及实例(二)
javascript计算器 -> 添加时间在屏显区左上角添加时间显示
效果图如下:
代码
初始化javascript 计算器
// 计算器初始化
calculator.prototype.init = function () {
this.addtdclick();
// 时间显示
this.showdate();
};
时间显示
// 在屏显区左上角显示时间日期
calculator.prototype.showdate = function () {
$("result-date").innertext = new date().format("hh:mm:ss eee yyyy-mm-dd");
var that = this;
if (this.timer) cleartimeout(this.timer);
this.timer = settimeout(function(){
that.showdate();
}, 1000);
};
时间格式化
date.prototype.format = function (datestr){}
通过定时器每隔一秒获取时间去显示
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
更多javascript 实现计算器时间功能详解及实例(二)。