-1

i was wondering if is it possibile to change entire css with another one (maybe a file) with a button click.

My idea is: i have this website with ugly design and when you click on this button all che design changing (like color, font, layout of elements etc) and make this "ugly" design a beauty design.

I think about 2 css files in assets folder as ugly.css and beauty.css. The page is using ugly.css and should switch to beauty.css on clicking on this button.

I want to change html too.

Thanks

  • You can do this with javascript. Examine: [How can you change the attached CSS file with Javascript?](https://stackoverflow.com/a/24087105/8929253) – sercan Dec 02 '20 at 19:58
  • Yes. See [this site](http://www.csszengarden.com/), which is well known for showcasing that exact thing. There are several ways of doing it, which I'm sure you can find by searching Stack Overflow and Google. – Scott Marcus Dec 02 '20 at 19:58
  • "I want to change html too"—so... you want to load a completely different page? Use a regular link? – ChrisGPT was on strike Dec 02 '20 at 20:42
  • Thank you to everyone! @Chris i think here entering in the game AJAX or Iframe because i want to click on button and load another html with different content. – Dario Esposito Dec 02 '20 at 21:41
  • @DarioEsposito, please review what's on-topic in the [help/on-topic] and then read [ask]. Unfortunately, your question isn't very clear at the moment. – ChrisGPT was on strike Dec 02 '20 at 21:48

1 Answers1

-1

you can use javascript to do so:

  document.getElementById.onclick=function(){                     //enter the id of button.
       document.getElementById.css("background-color","yellow",etc.) //here enter the id of     
                                                                        the element you 
                  }                                                      want to change.

You can also use jquery .

Anurag Hale
  • 133
  • 9
  • if he wants to swap an entire css file then this is way to complicated with a tendency of getting an unwanted error. Also you cause with it an inline-style that would oevrrule CSS but not entirely disable it. Changing the source of the CSS file is much easier, shorter and less likely to cause errors. – tacoshy Dec 02 '20 at 22:55