I'm working on a project for a client built on Twitter Bootstrap. He wants to have different colour schemes that the user can select from. For example have a Red Colour Scheme and a Blue Colour Scheme that the user can change through a menu up the top.
Is there any plugins for jQuery (or anything else for that matter) that will do this? All it really has to do is load a different CSS file I suppose, how would you go about doing this?
Alright, since you want to load different themes...
You can use jQuery to load different stylesheets
This could be a button click or another event that is triggered. So, what you would do is simply insert a new element into the head section of the page DOM. This can be done in a couple of lines of jQuery:
I hope this solves it...
Use Kickstrap. You can install themes from basically anywhere, make your own, includes themes from Bootswatch and it uses Less.js client-side to easily recompile your changes each time.
I tested this on IE11, Chrome, Firefox and it works:
1.
2.
Code:
In this case the theme files other than the original were named like this:
bootstrap-theme.min_ …. .css
. For example:bootstrap-theme.min_Cerulean.css
Changing the href of your style will, by itself, do nothing. The browser has already loaded your CSS and changing the HREF will not cause him to read the new file again.
Read the answer to this question, it might help you.
If a reload of the page is okay, you should probably do it on the server rather than through javascript by using some session value that defines what color scheme to use.