亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

課堂效果訓(xùn)練

original 2019-03-02 19:41:46 208
abstrait:<html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title></title>
</head>
<style>
* {
margin: 0;
padding: 0;
}
body {
font-family: "Microsoft YaHei";
}
ul,
li {
list-style: none;
}
#box {
width: 100px;
height: 100px;
background: red;
margin: 0 auto 20px;
}
#btn {
width: 720px;
margin: 0 auto;
overflow: auto;
}
#btn li {
float: left;
width: 100px;
height: 40px;
border: solid 1px #333;
text-align: center;
line-height: 40px;
margin: 0 10px;
box-sizing: border-box;
cursor: pointer;
font-size: 18px;
}
#btn li:hover {
border: solid 1px #fff;
background: #333;
color: #fff;
}
#btn li.on {
background: red;
}
</style>
<body>
<div id="box"></div>
<ul id="btn">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li class="on"></li>
</ul>
<script>
(function() {
var oBox = document.getElementById("box"),
aBtn = document.querySelectorAll("#btn li");
var arr = ["變寬", "變高", "變色", "重置", "隱藏", "顯示"];
var initWidht = oBox.clientWidth,
initHeight = oBox.clientHeight;
for (let i = 0; i < aBtn.length; i++) {
aBtn[i].innerHTML = arr[i];
aBtn[i].onclick = function() {
switch (i) {
case 0:
oBox.style.width = "200px";
aBtn[i].className = "on";
break;
case 1:
oBox.style.height = "200px";
aBtn[i].className = "on";
break;
case 2:
oBox.style.backgroundColor = "green";
aBtn[i].className = "on";
break;
case 3:
oBox.style.width = initWidht + "px";
oBox.style.height = initHeight + "px";
oBox.style.backgroundColor = "red";
oBox.style.display = "block";
for (var j = 0; j < aBtn.length; j++) {
aBtn[j].className = "";
}
break;
case 4:
oBox.style.display = "none";
aBtn[i].className = "on";
aBtn[5].className = "";
break;
case 5:
oBox.style.display = "block";
aBtn[i].className = "on";
aBtn[4].className = "";
break;
}
};
}
})();
</script>
</body>
</html>

盡量模塊化方便后期修改。

Professeur correcteur:西門大官人Temps de correction:2019-03-03 09:55:22
Résumé du professeur:代碼的結(jié)構(gòu)不太好 1、缺少必要的注釋,不方便閱讀 2、控制樣式的代碼建議分離出來成為一個獨立的方法 3、綁定事件onclick也可以獨立出來成為一個獨立的方法

Notes de version

Entrées populaires