当前位置:网站首页>Simple native JS tab bar switching
Simple native JS tab bar switching
2022-06-25 19:16:00 【Good first】
<!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;
}
.syr{
width: 600px;
height: 400px;
border: 1px solid red;
margin: 100px auto;
}
.item{
width: 100%;
height: 40px;
border: 1px solid red;
display: flex;
align-items: center;
justify-content: space-around;
}
.item span{
border: 1px solid red;
padding: 10px 70px;
}
.itemlist{
width: 100%;
height: 356px;
border: 1px solid red;
display: flex;
align-items: center;
justify-content: center;
}
.itemLists{
display: none;
}
.nones{
display: block;
}
</style>
</head>
<body>
<div class="syr">
<div class="item">
<span class="itemss nones"> Content of a </span>
<span class="itemss"> Content of the two </span>
<span class="itemss"> Content of the three </span>
</div>
<div class="itemlist">
<span class="itemLists nones"> Content of a </span>
<span class="itemLists"> Content of the two </span>
<span class="itemLists"> Content of the three </span>
</div>
</div>
<script>
var item = document.getElementsByClassName('itemss');
var itemLists = document.getElementsByClassName('itemLists');
// Add class nomenclature
for (let i = 0; i < item.length; i++) {
const element = item[i];
element.onclick = function () {
for (let k = 0; k < itemLists.length; k++) {
if (i == k) {
itemLists[k].classList.add('nones'); // Add with display block The name of the class
}else{
itemLists[k].classList.remove('nones');// Delete with display block The name of the class
}
}
}
}
// display Law
// for (let i = 0; i < item.length; i++) {
// const element = item[i];
// element.onclick = function () {
// console.log(i);
// for (let k = 0; k < itemLists.length; k++) {
// if (i == k) {
// itemLists[k].style.display = 'block'
// }else{
// itemLists[k].style.display = 'none'
// }
// }
// }
// }
</script>
</body>
</html>
边栏推荐
- Tcp/ip test questions (I)
- LNMP compilation and installation
- Current situation and trend analysis of China's glass packaging containers in 2021: the revenue of glass packaging containers increases year by year [figure]
- PHP synchronizes website content to hundreds of websites to improve SEO ranking
- System optimization method
- R语言使用DALEX包的model_profile函数基于条件依赖CDP方法解释多个分类模型中某个连续特征和目标值y的关系(Conditional Dependence Plots)
- JVM | runtime data area (heap space)
- Redis cache preheating & avalanche & breakdown & penetration
- User management and permissions
- Analysis on development scale and development trend of China's night economy industry in 2021 [figure]
猜你喜欢

Why are life science enterprises on the cloud in succession?

Does GoogleSEO need to change the friend chain? (e6zzseo)
![Overview and trend analysis of China's CT examination equipment industry in 2021 [figure]](/img/e0/d4ed9a9d91534be0d956414f6abaaa.jpg)
Overview and trend analysis of China's CT examination equipment industry in 2021 [figure]

Combing the latest Data Mining Event Scheme!

如何快速关闭8080端口

Detailed explanation of oauth2 - Introduction (I)

LeetCode-78-子集

云上弹性高性能计算,支持生命科学产业高速发展、降本增效

Web development solution to cross domain problems

什么是算子?
随机推荐
PHP synchronizes website content to hundreds of websites to improve SEO ranking
Kotlin compose terminate todo project Click to edit and modify todo
Favorite PHP debugging methods
Record Baidu search optimization thinking analysis
Analysis on planting area, output and import of sugarcane in Guangxi in 2021: the output of sugarcane in Guangxi accounts for 68.56% of the total output of sugarcane in China [figure]
Tcp/ip test questions (I)
PostgreSQL change table owner
QQ robot epidemic situation query / epidemic situation concern [latest beta2 version]
Analysis on market scale and supply of China's needle coke industry in 2020 [figure]
Leetcode-78-subset
2、 Hikaricp source code analysis of connection acquisition process II
JS get data
削足适履 - 谈谈赛道上的坡道改造
QQ机器人:群成员自我禁言管理【最新beta2版本】
MySQL transaction explanation
On Oracle full stack virtual machine -- graalvm
Gbpnzd firm offer for 14 months, simulation for 19 months, test stable
LNMP compilation and installation
最新数据挖掘赛事方案梳理!
Solidity get quarterly time