+ 1

How would i code a button that could change the theme color of a website or html document?

3rd Jul 2017, 3:42 AM
Hoeft Brian
Hoeft Brian - avatar
11 Answers
+ 5
I made this theme changer in jq b4, all I would do is put in words like #theme, #theme-dark, #theme-light etc into my css (internal) in place of color values .mytheme { background-color: #theme; } I had a color dropdown menu with predefined colors on it, then in jq I got the text from the style tag and replaced those values with color codes(for the dropdown selection), then set the new css a the pages css and it would work, but a problem with it was it would only change if I would refresh the page....probably not the best way to do that but it worked...sorta
3rd Jul 2017, 4:09 AM
MCJEH
MCJEH - avatar
+ 5
yeah I get that, hard to do complex stuff without knowing what ur doing lol
3rd Jul 2017, 4:12 AM
MCJEH
MCJEH - avatar
+ 4
you could set each theme color to separate classes (background, text, border etc) and then use those classes in ur html and change the class names in JavaScript
3rd Jul 2017, 3:46 AM
MCJEH
MCJEH - avatar
+ 3
Check this link: https://alistapart.com/article/alternate It talk about XHtml, but would be still valid for Html, at least for understanding how to handle alternate style sheet with JS ;)
3rd Jul 2017, 6:07 AM
visph
visph - avatar
+ 1
JavaScript is the best and simple options
3rd Jul 2017, 4:08 AM
JULIAN ANTHONY
JULIAN ANTHONY - avatar
+ 1
if u understand the theory then it will become easier for you to write the codes...in your preferred language
3rd Jul 2017, 4:14 AM
JULIAN ANTHONY
JULIAN ANTHONY - avatar
0
I'll have to try that.
3rd Jul 2017, 3:48 AM
Hoeft Brian
Hoeft Brian - avatar
0
would it be easier to make a copy of the css document with different themes and just use an a tag in a button to load different themes?
3rd Jul 2017, 3:56 AM
Hoeft Brian
Hoeft Brian - avatar
0
yeah but im still just trying to get the hang of JavaScript. i understand it in theory but have litte practice.
3rd Jul 2017, 4:10 AM
Hoeft Brian
Hoeft Brian - avatar
0
Right, i just found a video that shows how to change the css link by giving it an id and passing it threw a JavaScript function, it kinda helps but its still to vague.
3rd Jul 2017, 4:16 AM
Hoeft Brian
Hoeft Brian - avatar
0
I am a beginner .sorry
3rd Jul 2017, 5:15 AM
danielvarghese
danielvarghese - avatar