javascript - Changing all colors on the page with JS -


i'm trying make simple color switcher site js. issue being site has 2 possible style sheets, making little more difficult.

i have:

$(document).ready(function () { $('*').filter(function() {      return $(this).css('background-color') == "rgb(101, 31, 255)"  }).css('background-color', '#33b5e5') $('*').filter(function() {      return $(this).css('border-color') == "rgb(101, 31, 255)"  }).css('border-color', '#33b5e5') $('*').filter(function() {      return $(this).css('color') == "rgb(101, 31, 255)"  }).css('border-color', '#33b5e5') }); 

which hideous , horrible, iterates through elements can have color, , replaces other. issue being i'd have rerun not every page change, every single time div loaded, insane.

is there better way of changing of color 1 in style sheet color 2?

can use jquery add or remove specific class body on click event? in stylesheet, define new colour depending on whether or not .theme class exists.

this example:

$(".btn").click(function(){   $("body").toggleclass( "theme" ); }); 

then in stylesheet have setup this:

* {color:red;background:yellow;border-color:blue} .theme * {color:green;background:pink;border-color:orange} 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -