[JavaScript] JavaScript中if else条件语句使用范例 →→→→→进入此内容的聊天室

来自 , 2021-04-01, 写在 JavaScript, 查看 150 次.
URL http://www.code666.cn/view/fa183ba8
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <p>Click the button to get a time-based greeting.</p>
  6.  
  7. <button onclick="myFunction()">Try it</button>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. function myFunction()
  13. {
  14. var x="";
  15. var time=new Date().getHours();
  16. if (time<20)
  17.   {
  18.   x="Good day";
  19.   }
  20. else
  21.   {
  22.   x="Good evening";
  23.   }
  24. document.getElementById("demo").innerHTML=x;
  25. }
  26. </script>
  27.  
  28. </body>
  29. </html>
  30.  
  31. //javascript/7824

回复 "JavaScript中if else条件语句使用范例"

这儿你可以回复上面这条便签

captcha