sexycullen

daynight script bru

Jan 8th, 2022 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <!---- day/night toggle----->
  2.  
  3. <script>
  4. const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
  5.  
  6. if (currentTheme === 'night') {
  7. $( 'body' ).addClass( 'night');
  8. }
  9.  
  10. $(document).ready(function(){
  11. $('.daynight').click(function(){
  12. $(document).ready(function(){
  13. $('.daynight').click(function(){
  14. let theme = 'daynight';
  15. $('body').toggleClass('night');
  16. $('.daynight span').toggleClass('fa-sun');
  17. if ($('body').hasClass('night')) {
  18. theme = 'night';
  19. }
  20. localStorage.setItem('theme', theme);
  21. });
  22. });
  23. });
  24. });
  25. </script>
Add Comment
Please, Sign In to add comment