1
在我的主頁上有一個按鈕。該按鈕導致帶有選項卡的另一個頁面。只要點擊主頁上的特定按鈕,如何激活一個選項卡並顯示其內容?這是否可能發生,或者必須發生事件?如何使用JQuery使特定網址生效選項卡
if(location.hash) {
$('#tabbedContent').each(function(){
$(this).find("#champion" + location.hash.substr(1)).fadeIn();
});
} else {
$('#tabbedContent').each(function(){
$(this).find(':first-child').fadeIn();
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="box">
\t <div class="btnList">
\t \t <ul class="btnSet">
\t \t \t <li>
\t \t \t \t <a class="tab linkSection" href="#annual"><span>Nominate a Champion</span></a>
\t \t \t </li>
\t \t \t <li>
\t \t \t \t <a class="tab linkSection" href="#pathology"><span>Become a Champion</span></a>
\t \t \t </li>
\t \t \t <li>
\t \t \t \t <a class="tab double linkSection" href="#workshop"><span>Promote the Program</span></a>
\t \t \t </li>
\t \t \t <li>
\t \t \t \t <a class="tab double linkSection" href="#champion"><span>Contact a Champion</span></a>
\t \t \t </li>
\t \t </ul>
\t </div><!-- meetings tabbed section -->
\t <div class="tabbedContent onPage active" id="annual">
\t \t <div class="tabbedContent infoPage">
\t \t \t <div class="greyBox column col-50">
\t \t \t \t <h2>text</h2>
\t \t \t </div>
\t \t \t <div class="column col-50">
\t \t \t \t <div class="borderBox">
\t \t \t \t \t <h2>text</h2>
\t \t \t \t </div><br>
\t \t \t </div>
\t \t </div>
\t </div>
</div>
謝謝你,我會嘗試。 – Addy