jQueryを使用して非表示にする2つのタブがあります。しかし、今私は同じページにあるfiles
タブへのリンクを作らなければならない。私はこれで試してみます: <a href='#files' target='_blank'>Files</a>
jqueryを使用してタブにリンクします
しかし、選択する方法files
セクション?現在、デフォルトでは.current
クラスのため、application
セクションです。
$(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
ページには 'application'と' files'という2つのタブがあり、タブをクリックしてjqueryを使って 'current'にして表示しています。このページには 'files'というテキストがあり、' files'セクションへのリンクでなければなりません。しかし、私がそのようにすると: 'Files'、私はクラス 'current'を' files'セクションに追加する必要があります。どうやってするの? –