您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

使用js显示当前时间示例_jquery

2024/4/14 21:57:46发布16次查看
页面前台显示
复制代码 代码如下:
js脚本
复制代码 代码如下:
$(document).ready(function () {
//第一种
showtime();
//第二种
var clock = new clock();
clock.display($(#clock));
});//显示系统当前时间处理 第一种方法
function showtime() {
 var myarray = new array(7);
 var td = new date();
 myarray[0] = 星期日;
 myarray[1] = 星期一;
 myarray[2] = 星期二;
 myarray[3] = 星期三;
 myarray[4] = 星期四;
 myarray[5] = 星期五;
 myarray[6] = 星期六;
 weekday = td.getday();
 var h = td.gethours();
 var m = td.getminutes();
 var s = td.getseconds();
 var hstr = h;
 var mstr = m;
 var istr = s;
 if (h  if (m  if (s  $(#clock).innerhtml('当前时间:' + new date().tolocaledatestring() + + myarray[weekday] + + hstr + : + mstr + : + istr);
 settimeout(showtime, 1000);
}
//显示系统当前时间处理 第二种方法
function clock() {
var date = new date();
this.year=date.getfullyear();
this.month=date.getmonth()+1;
this.date=date.getdate();
this.day=newarray(星期日,星期一,星期二,星期三,星期四,星期五,星期六)[date.getday()];
this.hour=date.gethours()this.minute=date.getminutes()this.second=date.getseconds()
this.tostring=function(){
return现在时间是:+this.year+年+this.month+月+this.date+日+this.hour+:+this.minute+:+this.second++this.day;
};
this.tosimpledate=function(){
returnthis.year+-+this.month+-+this.date;
};
this.todetaildate=function(){
returnthis.year+-+this.month+-+this.date++this.hour+:+this.minute+:+this.second;
};
this.display=function(ele){
varclock=newclock();
ele.innerhtml=clock.tostring();
window.settimeout(function(){clock.display(ele);},1000);
};
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product