這篇文章主要介紹了js實現每日自動換一張圖片的方法,涉及javascript操作圖片與日期的相關技巧,非常簡單實用,需要的朋友可以參考下
本文實例講述了js實現每日自動換一張圖片的方法。分享給大家供大家參考。具體實現方法如下:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>無標題文檔</title>
- </head>
- <body>
- <a target="_blank" id="a"><img id="img" /></a>
- <script type="text/javascript">
- var imgSrc = new Date().getDate() +'.jpg';
- document.getElementById('img').src = imgSrc;
- document.getElementById('a').href = imgSrc ;
- </script>
- </body>
- </html>
希望本文所述對大家的javascript程序設計有所幫助。
新聞熱點
疑難解答
圖片精選