當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
关于JS的时间控制
關(guān)于JS的時(shí)間控制實(shí)現(xiàn)動(dòng)態(tài)效果及實(shí)例操作
<script>BOM //Bowers Object Model 瀏覽器對(duì)象模型setTimeout() // 延遲執(zhí)行一次setInterval() // 間隔執(zhí)行var a = 300;window.setTimeout('abc(a)',3000); // 自定義函數(shù)賦值function abc(i){alert(i);}//setInterval('alert(123)',2000);var dh = document.getElementById("dh");//alert(dh.offsetLeft);function move() {dh.style.marginLeft = dh.offsetLeft + 1 + 'px';}var x = window.setInterval('move()', 20);var y = window.setInterval('move()', 500);function clear() {window.clearInterval(x);}//清除間隔執(zhí)行window.setTimeout("clear()",2500);// 要執(zhí)行的代碼;間隔時(shí)間 window.setInterval('alert(123)',1000);</script>利用時(shí)間控制實(shí)現(xiàn)鐘表的操作<style>*{margin: 150px auto;width:500px; height:500px;}</style><body><div><span id="h"></span><span id="m"></span><span id="s"></span></div><script type="text/javascript">window.setInterval("time()",1000);自定義時(shí)間函數(shù)function time(){日期時(shí)間函數(shù)調(diào)用var time = new Date();document.getElementById("h").innerText = time.getHours() +':';document.getElementById("m").innerText = time.getMinutes() +':';document.getElementById("s").innerText = time.getSeconds();}</script></body>
轉(zhuǎn)載于:https://www.cnblogs.com/sglq/p/7357748.html
總結(jié)
- 上一篇: Day-5: Python高级特性
- 下一篇: 【CSS 】动画animation