• Resolved snippet24

    (@snippet24)


    So the idea is to change the icon to moon / sun for dark or normal mode. I don’t know how to retrieve the cookie value, the following code works except after clicking on a link while in dark mode, it loads the moon icon

    $(function() {
        $('.wpnm-button').click(function() {
          if($('body').hasClass('wp-night-mode-on')){
            $('.toggle-fontawesome').find('i').removeClass('fa-moon');
              $('.toggle-fontawesome').find('i').addClass('fa-sun');
        }
        else{
             $('.toggle-fontawesome').find('i').removeClass('fa-sun');
              $('.toggle-fontawesome').find('i').addClass('fa-moon');
        } 
        });
    });*/
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author markoarula

    (@markoarula)

    Hi,

    Sorry for the late reply, I haven’t been here for a while.

    You can get cookies in JS with document.cookie.

    Please let me know if you still need my help.

    Thread Starter snippet24

    (@snippet24)

    Hi, I would appreciate it, as I only know the basics of JS. Let me know if u need the link to my web (which has the button with the above mentioned problem)

    • This reply was modified 4 years ago by snippet24.
    Plugin Author markoarula

    (@markoarula)

    Hi,

    the link to your website would be very useful.

    You can probably achieve what you want without JS.

    Thread Starter snippet24

    (@snippet24)

    Alright here it is: https://www.tomastestart.cl
    The button is located in the bottom right corner.

    Plugin Author markoarula

    (@markoarula)

    As I can see, you just need to replace the moon icon with the sun icon.

    Please try with this CSS:

    #boton-darkmode a .fas:before {
      content: "\f185";
    }
    
    body.wp-night-mode-on #boton-darkmode a .fas:before {
      content: "\f186";
    }

    Let me know if that worked.

    Thread Starter snippet24

    (@snippet24)

    It works perfectly!! Ohh I had the mindset that it had to be done with JS.. thank you so much!! ??

    Have a nice weeek!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to toggle button class on cookie/active’ is closed to new replies.