久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      JavaScript怎樣獲取今天星期幾

      JavaScript獲取今天星期幾的方法:1、利用new關(guān)鍵詞來定義Date對(duì)象,語(yǔ)法為“new Date()”;2、利用getDay()方法通過定義的Date對(duì)象獲取今天星期幾即可,語(yǔ)法為“Date.getDay()”。

      JavaScript怎樣獲取今天星期幾

      本教程操作環(huán)境:windows10系統(tǒng)、javascript1.8.5版、Dell G3電腦。

      JavaScript怎樣獲取今天星期幾

      Date 對(duì)象用于處理日期和時(shí)間。

      可以通過 new 關(guān)鍵詞來定義 Date 對(duì)象。以下代碼定義了名為 myDate 的 Date 對(duì)象:

      有四種方式初始化日期:

      new Date(); new Date(value); new Date(dateString); new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]]);

      getDay() 方法可返回一周(0~6)的某一天的數(shù)字。

      注意: 星期天為 0, 星期一為 1, 以此類推。

      語(yǔ)法為:

      Date.getDay()

      示例如下:

      <html> <head> <meta charset="utf-8"> <title>123</title> </head> <body> <p id="demo">單擊按鈕顯示一周中的今天</p> <button onclick="myFunction()">點(diǎn)我</button> <script> function myFunction(){ var d = new Date(); var x = document.getElementById("demo"); x.innerHTML="星期"+d.getDay(); } </script> </body> </html>

      輸出結(jié)果:

      JavaScript怎樣獲取今天星期幾

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)