Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body>
	<div class="container-fluid">
					<h2>Tabs in jQuery.</h2>
					<h4>They switch</h4>

	<div class="row">

<div class="tab-panels col-xs-12">
<!-- creating tabs here -->

	<ul class="tabs">
		<li rel="panel-1" class="active"> Tab 1</li>
		<li rel="panel-2"> Tab 2</li>
		<li rel="panel-3"> Tab 3</li>
		<li rel="panel-4"> Tab 4</li>

	</ul>

	<div id="panel-1" class="panel active">
					<p> 1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </p>
	</div>
				 			
	<div id="panel-2" class="panel">
					<p > 2. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
	</div>
	<div id="panel-3" class="panel">
					<p> 3. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
	</div>
	<div id="panel-4" class="panel">
					<p> 4. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum </p>
	</div>

</div>

		</div> <!-- row ends here -->
	
	</div> <!--container end here -->

</body>
            
          
!
            
              body {
		 font: 1.5em "Tahoma", san-serif;
		 color: white;

		 padding:1em;
		 background-color: #301;
		}
	
	.tab-panels ul {
	    margin: 0;
    	padding: 0;
	}
	.tab-panels ul li {
		    list-style-type: none;
		    display: inline-block;
		    background: #c55;
		    margin: 0;
		    padding: .5em 1.5em;
		    border-radius: .5em .5em 0 0;
		    color: #fff;
		    font-weight: 50;
		    cursor: pointer;

					}

	.tab-panels ul li:hover {
		    color: #fff;
		    background: #b20;
							}

	.tab-panels ul li.active {
    		color: #fff;
    		background: #b20;
			
				}

	.tab-panels .panel  {
    		display:none;
    		background: white;
    		color: black;
    		padding: 1.5em;
		    border-radius: 0 0 .8em .8em;
			}

	.tab-panels .panel.active {
    display:block;
	}

            
          
!
            
              // Note to self: make it smarter
$(document).ready(function() {
                
                // Step -1 : Create an event for click to each panel
                $('.tab-panels .tabs li').on('click', function(){ //$-1 starts
                	$('.tab-panels .tabs .active').removeClass('active'); // removes active class from li that was clicked
                	$(this).addClass('active'); // adding the active class to this so switching tabs would switch the active class to the current li that was clicked and remove active class from previous li
               		var paneltoshow = $(this).attr('rel'); // storing and later on referencing li that was clicked using rel attribute. You can use anything else with say, data-yourIdname instead of rel. Upto you.

 					//alert(paneltoshow); 			              	
 					$('.tab-panels .panel.active').slideUp('100', function(){
						$(this).removeClass('active');  						//console.log(this);

 						$('#'+paneltoshow).delay('100').slideDown(function () {
		 					$(this).addClass('active');	 					//console.log(this);		
		 				});
		 			});

                }); //$-1 ends

 					
          

                });
            /* ready ends here */
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console