2

I want to create a simple style swicher using less.

I created a set of colored squares, and I would like by clicking on one of those, you can select a file. Css or even better, you can set the variable in the less file and generate a new style

The HTML-CSS code :

jsfiddle.net/AASH2/1/

Thanks in advance to those who will help me

Marco Gurnari
  • 159
  • 1
  • 3
  • 14
  • Dunno how to do it with the less, but with jQuery it can look like this: http://jsfiddle.net/AASH2/2/ – Stano Jul 30 '13 at 09:57
  • Thank you for your help. For example, if you wanted to select a particular file .css with one click, how could I do? Rather than simply change background thanks again – Marco Gurnari Jul 30 '13 at 10:02
  • Yet another one modification http://jsfiddle.net/AASH2/3/ Marco, I really don't know. Maybe somebody else will help you better. – Stano Jul 30 '13 at 11:43
  • You have to split your problem up into smaller problems. LESS is for generating CSS and is independent from switching between CSS files. How do you use LESS? Does the switching have to be in JavaScript or can it be server-side? – RoToRa Jul 30 '13 at 12:35

1 Answers1

1

You can change the href attribute of your link tag when click on the button

So using your example

$('li').on('click', function() {
    $('link').attr('href','new_file_path_here');
});

This is a basic example, you can give your link tag an id and target it that way

Also see How do I switch my CSS stylesheet using jQuery?

Community
  • 1
  • 1
Huangism
  • 16,278
  • 7
  • 48
  • 74