当前位置: 首页 > 工具软件 > JAVE > 使用案例 >

jave代码

叶鸿
2023-12-01

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <img src="">
    <p></p>
    <script>
        var nowTime = new Date();

        var h = nowTime.getHours();

        var text = document.querySelector("p");
        var img = document.querySelector("img");

        if (h < 12){
            text.innerText = "还没12点,现在起床太早了!";
            img.src = "../Resources/imgs/morning.gif";
        } else if (h < 18){
            text.innerText = "我就再睡半分钟!";
            img.src = "../Resources/imgs/afternoon.gif";
        } else {
            text.innerText = "天都快黑了,睡觉睡觉!";
            img.src = "../Resources/imgs/everning.gif";
        }
    </script>
</body>
</html>

 类似资料: