The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Dark/Light color switch Reply To: Dark/Light color switch


You won’t be able to switch colour on the pseudo elements (if that was the idea)…

Here’s some generic code, I’d probably choose the filter function for it:

$('button').click(function() {

  if ($(this).index() == 1) {

    $('.line').filter(function() {

      if ($(this).css('background-color') == 'rgb(241, 74, 255)') return this;
    .css('background-color', 'black');

Edit – actually, you can with a bit of CSS trickery: