javascript 模拟日历

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Document</title>
 6     <style>
 7         div {
 8             width: 800px;
 9             margin: 200px auto;
10             color: orange;
11             text-align: center;
12             font: 600 30px/30px "simSun";
13         }
14     </style>
15 </head>
16 <body>
17     <div></div>
18
19     <script>
20         //模拟日历需求:每天打开页面都能定时显示年月日和星期几
21         //步骤:创建一个当前日期的日期对象,获取其中的年月日和星期,赋值给div
22
23         //1.创建一个当前日期的日期对象
24         var date = new Date();
25         //2.获取其中的年月日和星期
26         var year = date.getFullYear();
27         var month = date.getMonth();
28         var day = date.getDate();
29         var week = date.getDay();
30         // console.log(year+" "+month+" "+day+" "+week);
31         //3.赋值给div
32         var arr =["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
33         var div = document.getElementsByTagName("div")[0];
34         div.innerText = "今天是:"+year+"年"+(month+1)+"月"+day+"日"+arr[week];
35     </script>
36 </body>
37 </html>

原文地址:https://www.cnblogs.com/knuzy/p/8836206.html

时间: 2024-08-30 10:05:04

javascript 模拟日历的相关文章

javascript模拟post提交隐藏地址栏的参数

想要隐藏地址栏的参数,就只能用javascript模拟post提交,下面是示例代码,需要的朋友可以看看 通过js模拟post提交 1:请求需要的参数过长,超过get允许的最大长度 2:想要隐藏地址栏的参数 view source print? 01 //新创建一个form表单 02 document.write('<form name=myForm></form>');  03 var myForm=document.forms['myForm'];  04 myForm.acti

JavaScript简易日历

<!DOCTYPE html PUBLIC "-//W3C//h2D XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/h2D/xhtml1-transitional.h2d"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

javascript模拟Windows系统下的扫雷游戏

javascript模拟Windows系统下的扫雷游戏. 说好的一周一篇随笔的,这才第三周就延迟交作业了,深深的自责中... 先玩一把 demo 很久以前写的 当时都没写注释的 刚加上了 (尼玛,好多自己都不认识了 ... ) 不足的敌方就是本来想写个游戏排名的统计的,等有空了再加上(好像每次都这么说 然后就等好久好久...) 还有就是没有实现:点击第一个格子不能是雷的功能 刚才在手机端 打开了下这篇文章 排版完全乱了... <style> ul{padding:0;list-style:no

JavaScript 模拟重载

/** * 参数个数对应 各自处理的函数 不指定 则执行 默认函数 * [ * d : function ( ) {} * , 0 : function ( ) {} * , 1 : function ( a ) {} * , 2 : function ( a, b ) {} * , 3 : function ( a, b , c ) {} * , 4 : function ( a, b , c, d ) {} * ] */ ! function () { var _reload = ( fun

javascript模拟post提交

通过js模拟post提交1:请求需要的参数过长,超过get允许的最大长度2:想要隐藏地址栏的参数 //新创建一个form表单document.write('<form name=myForm></form>');   var myForm=document.forms['myForm'];   myForm.action='runEmpAttendance';   myForm.method='POST'; var input = document.createElement('i

javascript模拟select下拉菜单

javascript模拟select下拉菜单: 由于自带的select下拉菜单确实是不够美观,并且美化的潜力也不够大,所以对外观要求比较高的网站,基本都要使用自定义的select下拉菜单,下面就提供了一个简单的例子供大家参考,代码实例如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="author" content="

Javascript之日历

<meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Javascript日历</title>  <table cellpadding="0" cellspacing="0" id="1">  <tr>  <td>  <style>

javascript 小日历

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="日历.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtm

用html+css+javascript制作日历

这是做好后的效果.不是很美观,还可以进一步完善. html+css代码如下: <!DOCTYPE html> <html> <head> <title>日历</title> <style type="text/css"> #div1{ width:425px; height:420px; border:1px solid gray; } #div2{ width: 390px; height: 390px; mar