gpt4 book ai didi

javascript - 使用 jquery 更改选项卡容器属性

转载 作者:行者123 更新时间:2023-11-28 16:24:07 25 4
gpt4 key购买 nike

我想改变被检测代码的属性

<li id="SR_R1_tab" class="t-Tabs-item a-Tabs-selected is-active" aria-controls="SR_R1" role="tab" aria-selected="false">
<a class="t-Tabs-link" href="#SR_R1" role="presentation" tabindex="-1">
<span>1<span>
</a>
</li>

<div id="SR_R1" class="a-Tabs-panel a-Tabs-before" data-label="1" role="tabpanel" aria-labelledby="SR_R1_tab" aria-hidden="true" style="display: block;" >

进入

<li id="SR_R1_tab" class="t-Tabs-item a-Tabs-before a-Tabs-selected is-active" aria-controls="SR_R1" role="tab" aria-selected="true"> 
<a class="t-Tabs-link" href="#SR_R1" role="presentation" >
<span>1<span>
</a>
</li>

<div id="SR_R1" class="a-Tabs-panel a-Tabs-before a-Tabs-element-selected" data-label="1" role="tabpanel" aria-labelledby="SR_R1_tab" aria-hidden="false" style="display: block;" >

使用 js 函数或 jquery。我正在使用甲骨文顶点。我对 jquery 和 js 的了解较少。我该怎么做?

最佳答案

Please Try below javascript.

1. Add the style first

div.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
div.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
div.tab button:hover {
background-color: #ddd;
}
div.tab button.active {
background-color: #ccc;
}
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}

2. Copy and paste below HTML

<div class="tab">
<button class="tablinks" onclick="openCity(event, 'London')">London</button>
<button class="tablinks" onclick="openCity(event, 'Paris')">Paris</button>
<button class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</button>
</div>

<div id="London" class="tabcontent">
<h3>London</h3>
<p>London is the capital city of England.</p>
</div>

<div id="Paris" class="tabcontent">
<h3>Paris</h3>
<p>Paris is the capital of France.</p>
</div>

<div id="Tokyo" class="tabcontent">
<h3>Tokyo</h3>
<p>Tokyo is the capital of Japan.</p>
</div>

3. Add below script in your webpage.

function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}

关于javascript - 使用 jquery 更改选项卡容器属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47281137/

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