Skip to content

Commit eeab097

Browse files
committed
Add activateLink method
1 parent 6db02d7 commit eeab097

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

rubbishtabs.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
var tabularize = function() {
2+
3+
var activateLink = function(elem) {
4+
$(".active").removeClass("active");
5+
elem.addClass("active");
6+
};
7+
28
var tabsWrapper = $(".tabs");
39
var tabs = tabsWrapper.children("div");
410
var tabLinks = tabsWrapper.find(".tab-link");
@@ -8,18 +14,16 @@ var tabularize = function() {
814
if(active) {
915
tabs.hide();
1016
$(active).show();
11-
$(".active").removeClass("active");
1217
$(".tab-link").each(function() {
1318
if($(this).attr("href") === active) {
14-
$(this).parent().addClass("active");
19+
activateLink($(this).parent());
1520
}
1621
});
1722
}
1823
tabLinks.click(function() {
1924
tabs.hide();
2025
$($(this).attr("href")).show();
21-
$(".active").removeClass("active");
22-
$(this).parent().addClass("active");
26+
activateLink($(this).parent());
2327
return false;
2428
});
2529
};

0 commit comments

Comments
 (0)