0
我有兩個選項卡,我隱藏和顯示使用jQuery。但現在我必須鏈接到files
選項卡,它位於同一頁面中。我試試這個: <a href='#files' target='_blank'>Files</a>
使用jquery鏈接到標籤
但是如何使被選files
一節?現在,這是application
部分,因爲默認爲.current
。
$(document).ready(function(){
$('.app-tabs span').click(function(event){
event.preventDefault();
var tab_id = $(this).attr('data-tab');
$('.app-tabs span').removeClass('current');
$('.applications-tab-content').removeClass('current');
$(this).addClass('current');
$("#"+tab_id).addClass('current');
});
});
.applications-tab-content{
display: none;
}
.applications-tab-content.current{
display: inherit;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<span class="app-tabs" id="app-tabs">
<span class="application current" data-tab="application">Data</span>
<span class="files" data-tab="files">Files</span>
</span>
<div id="application" class="applications-tab-content current"> some text here </div>
<div id="files" class="applications-tab-content"> some files here </div>
我無法理解您的問題。解釋你想要的。 – Mohammad
頁面上有2個選項卡 - 「應用程序」和「文件」,當您單擊其中一個選項卡時,使用jquery使其成爲「current」並顯示它。我在這個頁面上有一個文本,內容是:'files',並且必須是'files'部分的鏈接。但是當我這樣做時:'Files',我需要將'current'類添加到'files'部分。怎麼做? –