维科纳蒂 »
×
改变方向
在 Codepen 上打开
更改主题,深色/浅色
<!DOCTYPE html> <html lang='uk'> <body> <h2>JavaScript if .. else</h2> <p>A time-based greeting:</p> <p id="demo"></p> <script> const hour = new Date().getHours(); let greeting; if (hour < 18) { greeting = "Good day"; } else { greeting = "Good evening"; } document.getElementById("demo").innerHTML = greeting; </script> </body> </html>