Vertical Tabs with JQuery?

前端 未结 8 1788
一向
一向 2020-11-29 17:15

I want tabs along the left side of the page instead of across the top. I\'m already loading jQuery for other reasons (effects), so I prefer using jQuery to another UI frame

相关标签:
8条回答
  • 2020-11-29 17:52

    super simple function that will allow you to create your own tab / accordion structure here: http://jsfiddle.net/nabeezy/v36DF/

    bindSets = function (tabClass, tabClassActive, contentClass, contentClassHidden) {
            //Dependent on jQuery
            //PARAMETERS
            //tabClass: 'the class name of the DOM elements that will be clicked',
            //tabClassActive: 'the class name that will be applied to the active tabClass element when clicked (must write your own css)',
            //contentClass: 'the class name of the DOM elements that will be modified when the corresponding tab is clicked',
            //contentClassHidden: 'the class name that will be applied to all contentClass elements except the active one (must write your own css)',
            //MUST call bindSets() after dom has rendered
    
            var tabs = $('.' + tabClass);
            var tabContent = $('.' + contentClass);
            if(tabs.length !== tabContent.length){console.log('JS bindSets: sets contain a different number of elements')};
            tabs.each(function (index) {
                this.matchedElement = tabContent[index];
                $(this).click(function () {
                    tabs.each(function () {
                        this.classList.remove(tabClassActive);
                    });
                    tabContent.each(function () {
                        this.classList.add(contentClassHidden);
                    });
                    this.classList.add(tabClassActive);
                    this.matchedElement.classList.remove(contentClassHidden);
                });
            })
            tabContent.each(function () {
                this.classList.add(contentClassHidden);
            });
    
            //tabs[0].click();
        }
    bindSets('tabs','active','content','hidden');
    
    0 讨论(0)
  • 2020-11-29 17:54

    I've created a vertical menu and tabs changing in the middle of the page. I changed two words on the code source and I set apart two different divs

    menu:

    <div class="arrowgreen">
      <ul class="tabNavigation"> 
        <li> <a href="#first" title="Home">Tab 1</a></li>
        <li> <a href="#secund" title="Home">Tab 2</a></li>
      </ul>
    </div> 
    

    content:

    <div class="pages">
      <div id="first">
        CONTENT 1
      </div>
      <div id="secund">
        CONTENT 2
      </div>
    </div>
    

    the code works with the div apart

    $(function () {
        var tabContainers = $('div.pages > div');
    
        $('div.arrowgreen ul.tabNavigation a').click(function () {
            tabContainers.hide().filter(this.hash).show();
    
            $('div.arrowgreen ul.tabNavigation a').removeClass('selected');
            $(this).addClass('selected');
    
            return false;
        }).filter(':first').click();
    });
    
    0 讨论(0)
  • 2020-11-29 18:00

    Try here:

    http://www.sunsean.com/idTabs/

    A look at the Freedom tab might have what you need.

    Let me know if you find something you like. I worked on the exact same problem a few months ago and decided to implement myself. I like what I did, but it might have been nice to use a standard library.

    0 讨论(0)
  • 2020-11-29 18:02

    Another options is Matteo Bicocchi's jQuery mb.extruder tabs plug-in: http://pupunzi.open-lab.com/mb-jquery-components/jquery-mb-extruder/

    0 讨论(0)
  • 2020-11-29 18:02

    Have a look at Listamatic. Tabs are semantically just a list of items styled in a particular way. You don't even necessarily need javascript to make vertical tabs work as the various examples at Listamatic show.

    0 讨论(0)
  • 2020-11-29 18:03
    //o_O\\  (Poker Face) i know its late
    

    just add beloww css style

    <style type="text/css">
    
       /* Vertical Tabs ----------------------------------*/
     .ui-tabs-vertical { width: 55em; }
     .ui-tabs-vertical .ui-tabs-nav { padding: .2em .1em .2em .2em; float: left; width: 12em; }
     .ui-tabs-vertical .ui-tabs-nav li { clear: left; width: 100%; border-bottom-width: 1px !important; border-right-width: 0 !important; margin: 0 -1px .2em 0; }
     .ui-tabs-vertical .ui-tabs-nav li a { display:block; }
     .ui-tabs-vertical .ui-tabs-nav li.ui-tabs-selected { padding-bottom: 0; padding-right: .1em; border-right-width: 1px; border-right-width: 1px; }
     .ui-tabs-vertical .ui-tabs-panel { padding: 1em; float: right; width: 40em;}
    
    </style>
    

    UPDATED ! http://jqueryui.com/tabs/#vertical

    0 讨论(0)
提交回复
热议问题