<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin:0;
padding: 0;
list-style-type: none;
}
#all{
width: 600px;
height:600px;
margin:0 auto;
background-color: pink;
}
ul>li{
width: 198px;
height:100px;
float:left;
background-color: rgb(62, 194, 220);
border: 1px yellow solid ;
font-size: 30px;
color:pink;
text-align: center;
padding-top:25px;
}
#box1{
float:left;
width: 600px;
height: 473px;
background-color: rgb(150, 232, 203);
display: none;
font-size: 30px;
color: white;
text-align: center;
padding-top: 30px;
line-height:80px;
}
#box2{
float:left;
width: 600px;
height: 473px;
background-color: rgb(168, 233, 94);
display: none;
font-size: 30px;
color: white;
text-align: center;
padding-top: 30px;
line-height:80px;
}
#box3{
float:left;
width: 600px;
height: 473px;
background-color: rgb(223, 135, 231);
display: block;
font-size: 30px;
color: white;
text-align: center;
padding-top: 50px;
line-height:80px;
}
#all>ul>li.active{
background-color: yellow;}
</style>z
</head>
<body>
<div id = 'all'>
<ul>
<li id="list1">问题一</li>
<li id="list2">问题二</li>
<li id="list3">问题三</li>
</ul>
<div id = 'next'>
<div id = "box1" >
你最喜欢的水果:
<li> 西瓜:<input id = 'list1' type='checkbox'></li>
<li> 香蕉:<input id = 'list2' type='checkbox'></li>
<li> 苹果:<input id = 'list3' type='checkbox'></li>
<li> 荔枝:<input id = 'list4' type='checkbox'></li>
</div>
<div id = "box2">
你最喜欢的蔬菜:
<li> 青菜:<input id = 'list1' type='checkbox'></li>
<li> 花菜:<input id = 'list2' type='checkbox'></li>
<li> 豆芽:<input id = 'list3' type='checkbox'></li>
<li> 黄瓜:<input id = 'list4' type='checkbox'></li>
</div>
<div id = 'box3'>
你最喜欢的肉:
<li> 鸡肉:<input id = 'list1' type='checkbox'></li>
<li> 牛肉:<input id = 'list2' type='checkbox'></li>
<li> 羊肉:<input id = 'list3' type='checkbox'></li>
<li> 猪肉:<input id = 'list4' type='checkbox'></li>
</div>
</div>
</div>
<script>
//绑定对象
var ques1 = document.getElementById('list1')
var ques2 = document.getElementById('list2')
var ques3 = document.getElementById('list3')
var b1 = document.getElementById('box1')
var b2 = document.getElementById('box2')
var b3 = document.getElementById('box3')
//绑定点击事件
ques1.onclick = function(){
b1.style.display = 'block';
b2.style.display = 'none';
b3.style.display =' none';
}
ques2.onclick = function(){
b2.style.display = 'block';
b1.style.display = 'none';
b3.style.display = 'none';
}
ques3.onclick = function(){
b3.style.display = 'block';
b2.style.display = 'none';
b1.style.display = 'none';
}
</script>
</body>
</html>