Created
January 15, 2012 12:12
-
-
Save phawk/1615663 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Runs this function when the page loads | |
$(document).ready(structureTabs); | |
function structureTabs() | |
{ | |
// Insert a list to hold the tab buttons | |
$('#tabs').prepend('<ul id="tabbtns"></ul>'); | |
// Split the content up, starting with each h2 and all other content until the following h2 comes. | |
$('#tabs h2').each(function(index){ | |
$(this).nextUntil('h2').andSelf().wrapAll('<div id="tabs-'+(index+1)+'"></div>'); | |
var title = $(this).text(); | |
$('#tabbtns').append('<li><a href="#tabs-' + (index+1) + '">' + title + '</a></li>'); | |
}); | |
// Remove the h2 headings. | |
$('#tabs div h2').remove(); | |
} | |
jQuery(function() { | |
jQuery("#tabs").tabs(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment