图片时钟

图片时钟

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>title</title>

</head>
<body>
<img src="" alt="" id="img" />
<script>


  function f1() {
    //获取当前时间
    var time = new Date();
    //获取小时
    var hour = time.getHours();
    //获取秒
    var second = time.getSeconds();

    hour = hour < 10 ? "0" + hour : hour;
    second = second < 10 ? "0" + second : second;

    document.getElementById("img").src="meimei/"+hour+"_"+second+".jpg";
  }
  f1();
  //页面加载完毕后,过了1秒才执行函数的代码
  setInterval(f1,1000);




</script>

</body>
</html>
发布了116 篇原创文章 · 获赞 4 · 访问量 1763

猜你喜欢

转载自blog.csdn.net/qq_43618136/article/details/104292493