[HTML] 纯文本查看 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.div1 {
width: 200px; height: 200px; background-color: #B4B4B4; opacity:0;
}
.div2 { width: 200px; height: 200px; background-color: goldenrod; visibility: hidden;
}
.div2-2 { width: 100px; height: 100px; background-color: lightsalmon; visibility: visible;
}
.div3{ width: 200px; height: 200px; background-color: green; display: none;
}
.div4 { width: 200px; height: 200px; background-color: greenyellow; position: absolute; top:-99em; }
</style>
</head>
<body>
<div class="div1">1</div>
<div class="div2">2<div class="div2-2">2-2</div></div>
<div class="div3">3</div>
<div class="div4">4</div>
<script>
var div1 = document.querySelector(".div1");
var div2 = document.querySelector(".div2");
var div3 = document.querySelector(".div3");
var div4 = document.querySelector(".div4");
div1.οnclick=function () {
alert("div2");
};
div2.οnclick=function () {
alert("div2");
};
div3.οnclick=function () {
alert("div3");
};
div4.οnclick=function () {
alert("div4");
};
</script>
</body>
</html>