关于JS的时间控制实现动态效果及实例操作
<script>BOM //Bowers Object Model 浏览器对象模型setTimeout()
// 延迟执行一次setInterval()
// 间隔执行var a = 300;window.setTimeout('abc(a)',3000);
// 自定义函数赋值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);}//清除间隔执行window.setTimeout("clear()",2500);// 要执行的代码;间隔时间
window.setInterval('alert(123)',1000);</script>利用时间控制实现钟表的操作<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);自定义时间函数function time(){日期时间函数调用var time = new Date();document.getElementById("h").innerText = time.getHours() +':';document.getElementById("m").innerText = time.getMinutes() +':';document.getElementById("s").innerText = time.getSeconds();}</script></body>