first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
<!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>js_案例tabs</title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
.title {
height: 60px;
display: flex;
}
.title li {
width: 80px;
display: flex;
align-items: center;
justify-content: center;
}
.text {
height: 40px;
}
.text li {
width: 320px;
height: 40px;
display: none;
}
.text .active1{
display: block;
}
.active {
color: #fff;
background: red;
}
.active1{
color: black;
}
</style>
</head>
<body>
<ul class="title">
<li class="active">社会</li>
<li>娱乐</li>
<li>体育</li>
<li>军事</li>
</ul>
<ul class="text">
<li class="active1">社会新闻</li>
<li>娱乐新闻</li>
<li>体育新闻</li>
<li>军事新闻</li>
</ul>
</body>
<script>
//循环li标签,并绑定点击
_(".title li").forEach((v,i) => {
v.onclick = () =>{
_(".title li").forEach((val,index) => {
val.className = ""
_(".text li")[index].className = ""
})
v.className = "active"
_(".text li")[i].className = "active1"
}
})
function $(className) {
return document.querySelector(className);
}
function _(className) {
return document.querySelectorAll(className);
}
</script>
</html>