Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- $areas = $('#areas');
- if ($areas) {
- add_tabs({
- 'my-event': "My first tab",
- 'another-event': "My second tab"
- })
- }
- });
- function add_tabs(tabs) {
- if ( typeof(tabs) == "object" ) {
- $.each(tabs, function(event, text) {
- $new_tab = $('<li><a href="?event=' + event + '">' + text + '</li>');
- $areas.append(is_active(event, $new_tab));
- });
- }
- else
- throw 'Tabs must be a hash';
- }
- function is_active(event, $tab) {
- tab_active = (document.location.href.indexOf(event) != -1) ? true : false;
- if ( tab_active )
- $tab.addClass("active");
- return $tab;
- }
Add Comment
Please, Sign In to add comment