Browse files

only assuming the first link is the tab so i can have remove tab links

  • Loading branch information...
1 parent b756921 commit 577569f979138ada524e5bcd7326d967aba9477b @jnunemaker committed Jan 21, 2009
Showing with 11 additions and 9 deletions.
  1. +1 −1 jquery.tabify/index.html
  2. +10 −8 jquery.tabify/jquery.tabify.js
View
2 jquery.tabify/index.html
@@ -20,7 +20,7 @@
</script>
<style type="text/css" media="screen">
- li.active a {color:red;}
+ li.active a:first-child {color:red;}
</style>
</head>
View
18 jquery.tabify/jquery.tabify.js
@@ -1,24 +1,26 @@
+// Requires jQuery 1.3 as it uses live events
(function($) {
$.fn.tabify = function() {
var elements = this.each(function() {
var bar = $(this).addClass('tab_bar');
- var tabs = bar.find('a').each(function() {
+ var tabs = bar.find('li a:first').each(function() {
initTab(this);
}).live('click', function() {
- var bar = $(this).parents('.tab_bar');
- bar.find('li.active').removeClass('active');
- $(this).parent('li').addClass('active');
+ var tab = $(this);
+ var bar = tab.parents('.tab_bar');
- bar.find('a').each(function() {
- panelFor(this).hide();
- });
+ bar.find('li.active').removeClass('active');
+ tab.parent('li').addClass('active');
+ bar.find('li a:first').each(function() { panelFor(this).hide(); });
panelFor(this).show();
+
return false;
});
- $(tabs[0]).click();
+ var default_tab = $(tabs[0]);
+ default_tab.click();
});
function initTab(tab) {

0 comments on commit 577569f

Please sign in to comment.