Advertisement
tabvn

scripts.js

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