-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

5
  • You can do this with javascript. Examine: How can you change the attached CSS file with Javascript? Commented Dec 2, 2020 at 19:58
  • Yes. See this site, 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. Commented Dec 2, 2020 at 19:58
  • "I want to change html too"—so... you want to load a completely different page? Use a regular link? Commented Dec 2, 2020 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. Commented Dec 2, 2020 at 21:41
  • @DarioEsposito, please review what's on-topic in the help center and then read How to Ask. Unfortunately, your question isn't very clear at the moment. Commented Dec 2, 2020 at 21:48

1 Answer 1

-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 .

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.