treehouse : what would you like to learn today?
Web Design Web Development iOS Development

css style picker ?

  • hello everyone

    can you tell me how could I code a script or any other way that let the visitor choose his css style

    for example if he click a blue button the whole page will use a css that specify the blue color for elements etc.

  • There are quite a few...

    Try googling jQuery CSS Switcher

  • You can make your own easily enough. All you need to do is attach an id to the link element and switch the href to which it links to the location of a different file.In terms of getting the values to switch it to, you could create a select tag with the value for each option defined as a different page. An example of this form could be:

    <form method="post" action="#" id="style-selectior"> <label for="filename">Style:</label> <select name="filename" id="filename"> <option value="white.css">White</option> <option value="alt.css">Alternative</option> </select> <input type="submit" value="Choose" /> </form>

    Then you can latch onto what has been selected:

    $('#style-selector").on('change', function() {
      $('link').attr('href', $("style-selector").val() );
    });
    

    Nice clean solution that you can expand as needed without having a bunch of features you may not need!