js實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘
本文實(shí)例為大家分享了js實(shí)現(xiàn)動(dòng)態(tài)時(shí)鐘的具體代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html><html><head> <title>時(shí)鐘</title></head><script type='text/javascript'> function todou(n){ if(n<10){ return ’0’+n; } else { return ’’+n; } } window.onload=function(){ setInterval(function(){ var date = new Date(); var ma = document.getElementsByTagName(’img’); var str =todou(date.getHours())+todou(date.getMinutes())+todou(date.getSeconds()); for(var i=0;i<ma.length;i++){ ma[i].src=’images/’+str[i]+’.png’; } // alert(todou(date.getSeconds())); // var date = new Date(); //alert(todou(date.getSeconds())); } ,1000) }</script><body><div > <img src='http://m.b3g6.com/bcjs/images/0.png' height='90px'> <img src='http://m.b3g6.com/bcjs/images/0.png' height='90px'> 時(shí) <img src='http://m.b3g6.com/bcjs/images/0.png' height='90px'> <img src='http://m.b3g6.com/bcjs/images/0.png' height='90px'> 分 <img src='http://m.b3g6.com/bcjs/images/0.png' height='90px'> <img src='http://m.b3g6.com/bcjs/images/0.png' height='90px'> 秒</div></body></html>
示例展示:

更多JavaScript時(shí)鐘特效點(diǎn)擊查看:JavaScript時(shí)鐘特效專題
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 使用Python webdriver圖書館搶座自動(dòng)預(yù)約的正確方法2. Python3 json模塊之編碼解碼方法講解3. ASP基礎(chǔ)知識(shí)VBScript基本元素講解4. python 使用事件對(duì)象asyncio.Event來同步協(xié)程的操作5. Python 合并拼接字符串的方法6. Python字符串到字節(jié)的轉(zhuǎn)換。雙反斜杠問題7. Linux刪除系統(tǒng)自帶版本Python過程詳解8. ASP.NET MVC使用jQuery ui的progressbar實(shí)現(xiàn)進(jìn)度條9. Java Long類型對(duì)比分析10. Python sublime安裝及配置過程詳解

網(wǎng)公網(wǎng)安備