×

jquery 操作日期、星期、元素的追加的实现代码

作者:Terry2017.02.09来源:Web前端之家浏览:9246评论:0
关键词:JQueryJS
复制代码 代码如下:

<script language="javascript" >
$(document).ready(function(){
function show(){
var mydate=new Date();
var str = "" + mydate.getFullYear() + "年";
str += (mydate.getMonth() + 1) + "月";
str += mydate.getDate() + "日  <br/>";
str += mydate.toLocaleTimeString();
str += ":" + mydate.toLocaleTimeString();
str += ":" + mydate.getMilliseconds() + "  <br/>星期";
str += "天一二三四五六".charAt(mydate.getDay()) + "<br/>今年是闰年吗?:";
str += ((mydate.getFullYear() % 4 == 0 && mydate.getFullYear() % 100 != 0) || (mydate.getFullYear() % 400 == 0)) ? "是" : "不是"; };
function flush(){
$("#btnShow").click(show);
}
setInterval(show,1000);
});

</script>

html代码:
复制代码 代码如下:

<body>
<div>
<br/><br/><br/>
<button id="btnShow" >显示日期操作</button>
</br>
</div>
<div id="dateTime">

</div>
</body>

结果:

您的支持是我们创作的动力!
温馨提示:本文作者系Terry ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://www.jiangweishan.com/article/svg1486569600727.html

网友评论文明上网理性发言已有0人参与

发表评论: