Way to Allow User to Switch Page Colors?
-
I have a site with white font on black background. I would like to give users a way to switch to a black font on white background (e.g. clicking on a button). First I thought to go the easy way and try to find a plugin, but I couldn’t find any. So, I decided to try and implement a JS solution
I’ve added the following code (as it is perhaps obvious, it is linked to a button image with the id=”button”). It kinda works, in that it changes the background for the entire page to white, and the article text to black. However, text in e.g. headings or widget descriptions isn’t.
My questions:
1) How should I go about programmatically changing the related css value (e.g. h3) in the code below?
2) (Perhaps this ought to be the first question): is there any easier way to implement this? Some plugin I missed?var activated = 0; document.getElementById("button").addEventListener('click', function () { if (activated == 0) { document.body.style.backgroundColor = "white"; document.body.style.color = "black"; activated = 1; } else { document.body.style.backgroundColor = "black"; document.body.style.color = "white"; activated = 0; } });
The page I need help with: [log in to see the link]
- The topic ‘Way to Allow User to Switch Page Colors?’ is closed to new replies.