Javascript Turorial App - Day of Week App


Javascript Turorial App - Ứng dụng hiển thị ngày trong tuần

File index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="description" content="JavaScript app that displays the day of the week!" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Day of the week</title>   
<style>

body {
&nbsp; font-family:Helvetica, Arial, sans-serif;
&nbsp; margin: 50px;
&nbsp; background:#fff;
}


#container {

&nbsp; width:650px;
&nbsp; height:350px;
&nbsp; background-color: #00ffff;
&nbsp; margin:auto; /* This centers block elements like divs */
&nbsp; border-radius: 30px;

}
h1 {
&nbsp; font-size: 47px;
&nbsp; font-weight: 600px;
&nbsp; color:#fff;
&nbsp; text-transform:uppercase;
&nbsp; margin-bottom:20px;
&nbsp; margin-left: 170px;
&nbsp; background:#0000ff;
&nbsp; padding: 10px;
&nbsp; border-radius: 5px;
&nbsp; display:inline-block;
}

#weekday {
&nbsp; font-size: 80px;
&nbsp; color:#dd5800;
&nbsp; font-weight: 800px;
&nbsp; margin-left: 170px;
}

#phrase {
&nbsp; font-size: 40px;
&nbsp; color:#0000ff;
&nbsp; font-weight: 800;
&nbsp; margin-left: 170px;
}
</style> 
    <link rel="stylesheet" type="text/css" href="mystyle.css">
  </head>

  <body>
      <div id ="container">
        <h1>Today is :</h1>
        <div>
          <span id="weekday">Display day of the week.</span><br/>
          <span id="phrase">Display a quote</span>
        </div>

      </div>  
  <script src="myscript.js"></script>

  </body>

</html>

File script.js

var d = new Date();
var weekday = new Array(7);
weekday[0]=  "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

var date2 = new Date();
var weekday2 = new Array(7);
weekday2[0]=  "Time to chillax!";
weekday2[1] = "Monday morning blues!";
weekday2[2] = "Taco Time!";
weekday2[3] = "Two more days to the weekend.";
weekday2[4] = "The weekend is almost here...";
weekday2[5] = "Weekend is here!";
weekday2[6] = "Time to party!.";

var n = weekday[d.getDay()];
var n2 = weekday2[date2.getDay()];

var displayWeekday = document.getElementById('weekday');
var phrase = document.getElementById('phrase');

whatDayIsIt();

function whatDayIsIt() {
  
  displayWeekday.innerText = n ;
  phrase.innerText = n2;
  
}

 



Đóng góp ý kiến của bạn về bài học để admin liên hệ hoặc giúp nhé


CÔNG TY THIẾT KẾ WEBSITE CHUYÊN NGHIỆP

Kết nối với chúng tôi