Guest User

Untitled

a guest
Oct 17th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3. //Set the initial state: highlight the first button...
  4. $('#slidecontrols').find('li:eq(0)').addClass('selected');
  5.  
  6. //and hide all slides except the first one
  7. $('#slides').find('> div:eq(0)').nextAll().hide();
  8.  
  9. //actions that apply on click of any of the buttons
  10. $('#slidecontrols li').click( function(event) {
  11.  
  12. //turn off the link so it doesn't try to jump down the page
  13. event.preventDefault();
  14.  
  15. //un-highlight the buttons
  16. $('#slidecontrols li').removeClass();
  17.  
  18. //hide all the slides
  19. $('#slides > div').hide();
  20.  
  21. //highlight the current button
  22. $(this).addClass('selected');
  23.  
  24. //get the index of the current button...
  25. var index = $('#slidecontrols li').index(this);
  26.  
  27. //and use that index to show the corresponding slide
  28. $('#slides > div:eq('+index+')').show();
  29.  
  30. });
  31.  
  32. });
Add Comment
Please, Sign In to add comment