04-if.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. <!-- 写一段js代码 -->
  8. <script>
  9. // 一段逻辑
  10. function surprise(){
  11. // alert("hello 我是惊喜!")
  12. // 非零数字 判断为true
  13. // if(0){
  14. // console.log(true)
  15. // }else{
  16. // console.log(false)
  17. // }
  18. // // 非空字符串 判断为true
  19. // if('false'){
  20. // console.log(true)
  21. // }else{
  22. // console.log(false)
  23. // }
  24. // var monthStr = prompt("请输入月份:")
  25. // var month = Number.parseInt(monthStr)
  26. // switch(month){
  27. // case 3:
  28. // case 4:
  29. // case 5:
  30. // console.log("春天")
  31. // break
  32. // case 6:
  33. // case 7:
  34. // case 8:
  35. // console.log("夏天")
  36. // break
  37. // default:
  38. // console.log("不知道什么天")
  39. // }
  40. // 九九乘法表
  41. var i = 1
  42. while(i <= 9){
  43. var j = 1
  44. while(j <= i){
  45. document.write(j + "*" + i + "=" + i*j + "&nbsp;&nbsp;&nbsp;")
  46. j++
  47. }
  48. document.write("<br>")
  49. i++
  50. }
  51. }
  52. </script>
  53. </head>
  54. <body>
  55. <!-- onclick是点击按钮触发的事件 -->
  56. <button onclick="surprise()">点我点我点我</button>
  57. </body>
  58. </html>