|
@@ -0,0 +1,39 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <style>
|
|
|
+ .box {
|
|
|
+ width: 200px;
|
|
|
+ height: 200px;
|
|
|
+ background: #f00;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div class="box"></div>
|
|
|
+ <button id="btn1">显示</button>
|
|
|
+ <button id="btn2">隐藏</button>
|
|
|
+ <script>
|
|
|
+ // 需求:改变盒子的大小及颜色
|
|
|
+ // 显示在浏览器五秒后改变
|
|
|
+ var box = document.querySelector(".box");
|
|
|
+ var btn1 = document.getElementById("btn1");
|
|
|
+ var btn2 = document.getElementById("btn2");
|
|
|
+ setTimeout(()=>{
|
|
|
+ console.log(box);
|
|
|
+ box.style.width = "300px";
|
|
|
+ box.style.height = "300px";
|
|
|
+ box.style.background = "#00f";
|
|
|
+ },5000)
|
|
|
+ btn1.onclick = function() {
|
|
|
+ box.style.display = "block";
|
|
|
+ }
|
|
|
+ btn2.onclick = function() {
|
|
|
+ box.style.display = "none";
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|