Blogger Ever

Create multiple or dynamic tabs using pure Jquery [update]

Create multiple or dynamic tabs using pure Jquery

Using of Jquery UI tabs or Jquery plugin is not a bad deal but they do increase the page loading time whereas my practice is to minimize the loading time as much as I can that is the reason I've developed simple animated tabs with a snippet of Jquery why don't you look at the demo below and then tutorial.


See the Pen esKCD by Mohammad Hamza Dhamiya (@mohammadhamza) on CodePen


As I told the giant script can increase your page script however the below Jquery is too simple and minimized so what the script says.

$('.content-canvas div:first-child').show();
$('.tab-button span:first-child').addClass('active');

When the page will be loaded three events will be triggered.
  • All div inside class='content-canvas' will be hide.
  • The first div inside the class='content-canvas' will be show.
  • The first button will have the class='active'
Then the second event will be triggered when the button will be clicked that is
 var currentclass=$(this).attr('class');
All the buttons having the class='active' will be removed and then the var currentclass will calculate the class of the clicked button.After that the clicked button will have the class='active'.
if($(this).attr('class')==currentclass) {
After getting the class of the clicked button,the condition will be applied on each content.That is if any of the content container have the class which is equals to the currentclass will be show others will be hide.

Holla Done,if you didn't got anything our comments are always open.

2013-2016 Copyright Blogger E\ver . Coded, managed and founded by Mohammad Hamza (@hamzadhamiya) . Hosted on Blogger and fonts used are Raleway and Open Sans.