/ 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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** @id sipleSwitcher * @classDescription Very simple style switcher using jQuery */ $(document).ready(function(){ $('#styleSwitch .button').bind('click', function(){ $('body').removeClass();//remove all the other classes $('#styleSwitch .button').removeClass('selected'); $(this).addClass('selected'); switch(this.id){ case 'style1': $('body').addClass('style1'); break; case 'style2': $('body').addClass('style2'); break; case 'style3': $('body').addClass('style3'); break; } return false; }); });
Comments
