JSFiddle - React, Tailwind, and code Playground

by Stev Peifer

HTML

<div id="some-id">
<div> <!-- This is your first (0) tab -->
Contents0
</div>
<div> <!-- This is your second (1) tab -->
Contents1
</div>
</div>

JavaScript

/*
 * Tab - One Tab To Rule Them All.
 * By Stev Peifer (http://www.tip.it)
*/
(
        function($){
                $.fn.tab=function(option){
                    //~ Create objects and default options
                        var defaultOption={
                            align:'left',
                            padding:'5',
                            select:'0',
                            speed:'1000',
                            tabs:[],
                            title:'',
                            width:'670'
                        };
                        var option=$.extend({},defaultOption,option);
                        var _this=$.extend({},this,
                            {
                                busy:0,
                                clicked:0
                            }
                        );
                    //~ Check and throw errors for invalid options
                        if(option.align!='left'&&option.align!='center'&&option.align!='right')
                            $.error('$.tab() - Unexpected value specified for option: align.');
                        if(isNaN(option.padding=parseInt(option.padding)))
                            $.error('$.tab() - Unexpected value specified for option: padding.');
                        if(isNaN(option.select=parseInt(option.select))||option.select<0||option.select>_this.find('>div').length-1)
                            $.error('$.tab() - Unexpected value specified for option: select.');
                        if(isNaN(option.speed=parseInt(option.speed)))
                            $.error('$.tab() - Unexpected value specified for option: speed.');
                        if(typeof option.tabs!='object'||option.tabs.length==0||option.tabs.length!=_this.find('>div').length)
                            $.error('$.tab() - Unexpected value specified for option: tabs.');
                        if(typeof option.title!='string'&&typeof option.title!='number')
           ...