好吧我懷疑有人會讀這個,但我自己解決了。現在公平地說,這對我的ID系統來說有點特殊,但是這裏是
每個選項卡都是導航欄的無序列表中的一個列表項。這很重要,因爲「活動」類放置在LIST項目上,而不是TAB本身。
每個標籤內容都有一個標識爲「Project-Tab」的ID,其中Project是該特定項目的名稱。
然後每個選項卡鏈接(href)到該標籤的內容,標題爲「Project」,其中project是該特定項目的名稱。
現在在每一個,我已經連接到我添加了一個類「Overview_Tab」
由於這裏說明的標籤內容的「項目卡」我的概述部分是解決
$('.Overview_Tab').click(function(){
/* Gets the href of the clicked "project card" which is a link to the tab
content for that project. I then concatenate '-Tab' onto the end to get the
id of the associated tab (as explained above) */
var target = $(this).attr('href')+'-Tab';
// Get the parent (the list item containing that tab div) this is where
"active" needs to be placed
var target_parent = $(target).parent();
// Remove the active class on the overview tab
$('#Overview-Tab').parent().removeClass('active');
// Add active class to the target parent
target_parent.addClass('active');
});
因此,爲了概括這一點,您希望您的標籤ID和tabContent ID相同,只需在標籤ID的末尾添加「-Tab」即可。
選擇要添加到正在複製一個選項卡(我撿「Overview_Tab」但因爲它的HTML和JS的函數之間的匹配,你可以,只要把任何東西在那裏)
元素任何類名