Advertisement
tabvn

Untitled

Jul 26th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.  
  3.     $(document).ready(function () {
  4.  
  5.         /** Begin main tabs */
  6.  
  7.  
  8.         $('.table-sections').find('.table-section').removeClass('selected');
  9.  
  10.         // first tab is active as default.
  11.         $('.table-sections').find('.table-section:first-child').addClass('selected');
  12.  
  13.         $('.table-sections').find('.table-section').on('click', function (e) {
  14.  
  15.             $mainTab = $(this);
  16.  
  17.             $mainTab.parents('.table-sections').find('.table-section').removeClass('selected');
  18.  
  19.             // do select or close current clicked on tab
  20.             if ($mainTab.hasClass('selected')) {
  21.                 // meaning tab is selected and now click again it should be close.
  22.                 $mainTab.removeClass('selected');
  23.             } else {
  24.  
  25.                 // tab is closed and need open
  26.                 $mainTab.addClass('selected').show();
  27.             }
  28.  
  29.             e.preventDefault();
  30.         })
  31.         /** END main tabs */
  32.  
  33.  
  34.         /** Begin sub tabs */
  35.         // default first of tab is active, so we need selected it
  36.         $('.table-section-tabs').find('.table-section-tab:first').addClass('selected');
  37.  
  38.         // tab section click on
  39.         $('.table-section-tabs').find('.table-section-tab').on('click', function (e) {
  40.             $thisTab = $(this);
  41.  
  42.             // close other tabs
  43.             $thisTab.parents('.table-section-tabs').find('.table-section-tab').removeClass('selected');
  44.  
  45.  
  46.             // do select or close current clicked on tab
  47.             if ($thisTab.hasClass('selected')) {
  48.                 // meaning tab is selected and now click again it should be close.
  49.                 $thisTab.removeClass('selected');
  50.             } else {
  51.  
  52.                 // tab is closed and need open
  53.                 $thisTab.addClass('selected');
  54.             }
  55.  
  56.             e.preventDefault();
  57.         });
  58.  
  59.         /** End sub tabs */
  60.  
  61.  
  62.     });
  63.  
  64. }(jQuery));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement