HTML选项卡效果完整代码(JavaScript)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
*{
margin:0;
padding:0;
list-style-type: none;
html滚动效果代码}
.title{
display: flex;
}
.container{
width:500px;
border:1px solid red;
margin:100px auto;
}
.title{
display: flex;
}
.title li{
flex:1;
padding:10px 0;
text-align: center;
}
.title li.active{
background-color: #0000FF;
color: #FFFFFF;
}
</style>
</head>
<body>
<div class="container">
<ul class="title">
<li class="active">⽕车票</li>
<li>汽车票</li>
<li>飞机瓢</li>
</ul>
<ul class="content" >
<li>⽕车票111111*********</li>
<li >汽车票11111111111111111</li>
<li >飞机瓢111111*********</li>
</ul>
</div>
<script>
let title = ElementsByClassName('title')[0]
let content = ElementsByClassName('content')[0]
let titlelist = title.children
let contentlist = content.children
for(let i =0; i < titlelist.length; i++){
let item = titlelist[i];
let active = ElementsByClassName('active')[0]
ve('active')
item.classList.add("active")
for(let j =0; j < titlelist.length; j++){
contentlist[j].style.display ="none"
}
contentlist[i].style.display ="block"
contentlist[i].style.display ="block" }
}
</script>
</body>
</html>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。