Advertisement
salmancreation

sitch css

Jan 7th, 2020
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. function toggleTabWithSwitch() {
  2.  
  3. var toggleSwitch = $('#switch-toggle-tab label.switch');
  4. var TabTitle = $('#switch-toggle-tab li');
  5. var monthTabTitle = $('#switch-toggle-tab li.month');
  6. var yearTabTitle = $('#switch-toggle-tab li.year');
  7. var monthTabContent = $('#month');
  8. var yearTabContent = $('#year');
  9. // hidden show deafult;
  10. monthTabContent.fadeIn();
  11. yearTabContent.fadeOut();
  12.  
  13. function toggleHandle() {
  14. if (toggleSwitch.hasClass('on')) {
  15. yearTabContent.fadeOut();
  16. monthTabContent.fadeIn();
  17. monthTabTitle.addClass('active');
  18. yearTabTitle.removeClass('active');
  19. } else {
  20. monthTabContent.fadeOut();
  21. yearTabContent.fadeIn();
  22. yearTabTitle.addClass('active');
  23. monthTabTitle.removeClass('active');
  24. }
  25. };
  26. monthTabTitle.on('click', function() {
  27. toggleSwitch.addClass('on').removeClass('off');
  28. toggleHandle();
  29. return false;
  30. });
  31. yearTabTitle.on('click', function() {
  32. toggleSwitch.addClass('off').removeClass('on');
  33. toggleHandle();
  34. return false;
  35. });
  36. toggleSwitch.on('click', function() {
  37. toggleSwitch.toggleClass('on off');
  38. toggleHandle();
  39. });
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement