Change between Styles with Javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Change between Styles with Javascript

How can I change i.e my first css style style1.css to the second one style2.css with Javascript? Is that even possible ? Or would it be "easier" to just change all the lines in style1.css with a script?

6th Nov 2016, 5:51 AM
Skangel
Skangel - avatar
1 Answer
+ 2
Okay, I got it, I used this: HTML: <link rel="stylesheet" id="pagestyle" href="/styles/style1.css"> JS: function swapStyleSheet(sheet){ document.getElementById('pagestyle').setAttribute('href', sheet); swapStyleSheet("/styles/style2.css"); Thanks anyway :)
6th Nov 2016, 7:40 PM
Skangel
Skangel - avatar