4.demo.html 602 B

1234567891011121314151617181920212223242526
  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. <style>
  8. #box {
  9. width: 200px;
  10. height: 200px;
  11. background: #f00;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <div id="box"></div>
  17. <button>放大</button>
  18. <script>
  19. var box = document.getElementById("box");
  20. var btn = document.querySelector("button");
  21. btn.onclick = function() {
  22. box.style.width = 600 + "px";
  23. }
  24. </script>
  25. </body>
  26. </html>