1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Document</title>6 <style>7 Div{8 width:800px;9 margin:200px Auto;Ten Color:Orange; One text-align:Center; A Font:30px/30px "SimSun"; - } - </style> the </Head> - <Body> - <Div></Div> - + <Script> - //Simulated calendar requirements: Every day to open the page can be displayed on a regular date and day of the week + //Step: Create a Date object of the current date, get the month date and day of the week, assign a value to the DIV A at //1. Create a Date object of the current date - varDate= NewDate (); - //2. Get the date and day of the week - var Year=date.getfullyear (); - varMonth=date.getmonth (); - var Day=date.getdate (); in varWeek=Date.getday (); - //Console.log (year+ "" +month+ "" +day+ "" +week "); to //3. Assigning a value to a div + vararr=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; - varDiv=document.getElementsByTagName ("Div")[0]; the Div.innertext= "today is:"+ Year+"years"+(Month+1)+"Month"+ Day+"Day"+Arr[week]; * </Script> $ </Body>Panax Notoginseng </HTML>
JavaScript Simulation Calendar