gpt4 book ai didi

javascript - 如何使用项目符号和箭头添加/删除类

转载 作者:行者123 更新时间:2023-11-29 19:09:08 25 4
gpt4 key购买 nike

<分区>

当用户点击相应的数字或上一个/下一个箭头时,我无法弄清楚如何在 div 中添加和删除一个类。

请注意第二项和第二个导航栏上的“事件”类。我希望在用户单击“1”或“上一个”箭头时删除该类并将其添加到第一项和导航。

.wrap {
display: block;
width: 200px;
margin: 50px auto;
text-align: center;
}

.nav {
margin-bottom: 10px;
}
.nav a {
padding: 5px;
}
.nav a:hover {
font-weight: 900;
cursor: pointer;
}
.nav a.active {
border-bottom: 1px solid black;
font-weight: 900;
}

.prev, .next {
display: inline-block;
padding: 5px;
}
.prev:hover, .next:hover {
font-weight: 900;
cursor: pointer;
}

.items div {
display: none;
padding: 25px;
}
.items .one {
background: red;
}
.items .two {
background: green;
}
.items .three {
background: blue;
}
.items .active {
display: inline-block;
}
<div class="wrap">
<div class="nav">
<a class="one">1</a>
<a class="two active">2</a>
<a class="three">3 </a>
</div>
<div class="items">
<span class="prev"><</span>
<div class="one">ONE</div>
<div class="two active">TWO</div>
<div class="three">THREE</div>
<span class="next">></span>
</div>
</div>

http://codepen.io/bbbenji/pen/WovJEM

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com