Posted By

1man on 01/10/08


Tagged

style jquery example switcher


Versions (?)

Who likes this?

11 people have marked this snippet as a favorite

abhisek
martingoldszein
chrisaiv
l1r
marcoba
GiteshDang
vkolev
seanpowell
aegony
Snowalker
_duddy


jQuery Simple Style Switcher


 / Published in: JavaScript
 

Very simple style switcher using jquery. Takes 3 links with id's on each. When one is clicked various styles are removed, then a new one is added.

  1. /** @id sipleSwitcher
  2. * @classDescription Very simple style switcher using jQuery
  3. */
  4. $(document).ready(function(){
  5. $('#styleSwitch .button').bind('click', function(){
  6. $('body').removeClass();//remove all the other classes
  7. $('#styleSwitch .button').removeClass('selected');
  8. $(this).addClass('selected');
  9. switch(this.id){
  10. case 'style1':
  11. $('body').addClass('style1');
  12. break;
  13. case 'style2':
  14. $('body').addClass('style2');
  15. break;
  16. case 'style3':
  17. $('body').addClass('style3');
  18. break;
  19. }
  20. return false;
  21. });
  22. });

Report this snippet  

You need to login to post a comment.