js實現(xiàn)動態(tài)時鐘
本文實例為大家分享了js實現(xiàn)動態(tài)時鐘的具體代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html><html><head> <title>時鐘</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://www.leifengta.com.cn/bcjs/images/0.png' height='90px'> <img src='http://www.leifengta.com.cn/bcjs/images/0.png' height='90px'> 時 <img src='http://www.leifengta.com.cn/bcjs/images/0.png' height='90px'> <img src='http://www.leifengta.com.cn/bcjs/images/0.png' height='90px'> 分 <img src='http://www.leifengta.com.cn/bcjs/images/0.png' height='90px'> <img src='http://www.leifengta.com.cn/bcjs/images/0.png' height='90px'> 秒</div></body></html>
示例展示:

更多JavaScript時鐘特效點擊查看:JavaScript時鐘特效專題
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Android table布局開發(fā)實現(xiàn)簡單計算器2. 理解PHP5中static和const關(guān)鍵字3. jQuery 實現(xiàn)DOM元素拖拽交換位置的實例代碼4. php模擬實現(xiàn)斗地主發(fā)牌5. IntelliJ IDEA安裝插件的方法步驟6. phpstorm恢復(fù)默認(rèn)設(shè)置的方法步驟7. Vue封裝一個TodoList的案例與瀏覽器本地緩存的應(yīng)用實現(xiàn)8. Python random庫使用方法及異常處理方案9. Vuex localStorage的具體使用10. .Net Core使用Coravel實現(xiàn)任務(wù)調(diào)度的完整步驟

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