我有一個簡單的選項卡腳本在內容之間交替。目前,該腳本可以在單擊該選項卡類時對其進行更改,但是我希望鏈接到選項卡正文副本內的選項卡,並確保活動選項卡接收要選擇的適當類。更改選項卡選擇身體鏈接點擊
http://jsfiddle.net/jdmcculley/aMBj2/2/
$(document).ready(function() {
$('.tabs a').click(function(){
switch_tabs($(this));
});
switch_tabs($('.defaulttab'));
$('.tab-content .img-frame a').click(function(){
switch_tabs($(this));
});
});
function switch_tabs(obj)
{
$('.tab-content').hide();
$('.tabs a').removeClass("selected");
var id = obj.attr("rel");
$('#'+id).show();
obj.addClass("selected");
}
什麼是 「正確」 的課?在我的回答中,我從舊標籤中刪除'selected'類並將其添加到新標籤。在更改標籤時是否還有其他類需要交換? – j08691 2013-03-15 17:25:11