2017年7月3日 星期一

[JS]網頁學習 第六章 JS Window, JS Timing 小節 心得小記

var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

原來宣告變數也能用 or 表示
----

<body>

<p>A script on this page starts this clock:</p>

<p id="demo"></p>

<button onclick="clearInterval(myVar)">Stop time</button>

<script>
var myVar = setInterval(myTimer ,1000);
function myTimer() {
    var d = new Date();
    document.getElementById("demo").innerHTML = d.toLocaleTimeString();
}
</script>


</body>

覺得這個計時器、停止時間按鈕的範例很重要,先記下來
----

More Examples

沒有留言:

張貼留言