85 lines
1.9 KiB
HTML
85 lines
1.9 KiB
HTML
<!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>tabs切换</title>
|
|
<style>
|
|
html,
|
|
body,
|
|
div,
|
|
ul,
|
|
li,
|
|
h1,
|
|
h2,
|
|
h3,
|
|
h4,
|
|
h5,
|
|
h6,
|
|
p,
|
|
dl,
|
|
dt,
|
|
dd,
|
|
ol,
|
|
form,
|
|
input,
|
|
textarea,
|
|
th,
|
|
td,
|
|
select {
|
|
margin: 0;
|
|
padding: 0;
|
|
list-style: none;
|
|
}
|
|
|
|
.title {
|
|
height: 45px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-around;
|
|
}
|
|
.show_title{
|
|
color: red;
|
|
}
|
|
.content li{
|
|
display: none;
|
|
}
|
|
.show_content{
|
|
display: inline-block !important;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="tabs">
|
|
<ul class="title">
|
|
<li class="show_title">推荐</li>
|
|
<li>游戏</li>
|
|
<li>热点</li>
|
|
</ul>
|
|
<ul class="content">
|
|
<li class="show_content">推荐的内容</li>
|
|
<li>游戏的内容</li>
|
|
<li>热点的内容</li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
var title = document.querySelectorAll(".title li")
|
|
var content = document.querySelectorAll(".content li")
|
|
title.forEach(function (vao,index) {
|
|
// console.log(vao)
|
|
vao.onclick = function () {
|
|
// console.log(vao)
|
|
title.forEach(function (asd,bb) {
|
|
asd.classList.remove("show_title")
|
|
content[bb].classList.remove("show_content")
|
|
})
|
|
vao.classList.add("show_title");
|
|
content[index].classList.add("show_content")
|
|
}
|
|
})
|
|
</script>
|
|
</html> |