Skip to main content

DOM


index.html 

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>DOM</title>
    <style>
      .dark {
        background-color: rgb(0, 0, 0);
        color: white;
      }

      .theme {
        margin: 10px;
        padding: 10px;
        border: 0;
        border-radius: 10px;
        background-color: rgb(139, 48, 48);
        color: white;
        font-size: 16px;
        text-transform: uppercase;
        font-weight: bold;
        cursor: pointer;
      }
    </style>
  </head>
  <body>
    <div class="wrapper">
      <button class="theme" id="theme">Dark Mode</button>
    </div>
    <script src="js.js"></script>
  </body>
</html>

    js.js


const btn = document.getElementById("theme");

function changeBg(color, text) {
  document.body.style.backgroundColor = color;
  btn.innerText = text;
}

//let currentTheme;
// btn.addEventListener("click", (e) => {
//    currentTheme = currentTheme === "dark" ? "light" : "dark";
//    console.log(e);
//    // console.log(`changed theme chnage to theme ${currentTheme} `);
//     if (currentTheme == "light") {
//     changeBg("black", "LIGHT MODE");
//   } else {
//      changeBg('white', 'DARK MODE')
//   }
// });

let currentTheme;
btn.addEventListener("click", (e) => {
  if (!currentTheme || currentTheme == "dark") {
        currentTheme = "light";
        changeBg("black", "LIGHT MODE");
   }  else {
          currentTheme = "dark";
          changeBg('white', 'DARK MODE')
   }
   console.log(currentTheme);
 });

Comments

Popular posts from this blog

useful bookmarks

Bookmarks Toolbar Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar 12 best web development blogs you should be reading There are loads of great web development blogs out there. Check out our list of the 12 best web development blogs every developer should be reading! Web Slice Gallery http://localhost//bootstrap/projects/catholic/index.html ↔ Responsive design testing tool – Viewport Resizer – Emulate various screen resolutions - Best developer device testing toolbar '+d.title+'%20-%20Responsive%20test %C3%97 I I Tablet%20Portrait Tablet%20Landscape iPhone%20Landscape iPhone%20Portrait Auto ')})());" ADD_DATE="1448873016" LAST_MODIFIED="1448873016">RWD Bookmarklet Web Designer - TechRepublic This blog offers tips for the beginner and the expert for designing and programming for web sites, including how to maximize them for mobile viewing. An A-Z Index of the Bash command line | SS64.com An A-Z...

orientation:landscape

<style> /* .page { height: 92%; } .main-content { height: 100%; overflow-x: hidden; overflow-y: auto; } @media(min-width:1281px) and (orientation:landscape){ .page { height: 84%; } } @media(max-width:1280px) and (orientation:landscape){ .page { height: 82%; } } @media(max-width:1024px) and (orientation:landscape){ .page { height: 87%; } } @media(max-width:736px) and (orientation:landscape){ .page { height: 74%; } } @media(max-width:600px) and (orientation:landscape){ .page { height: 77%; } } @media(max-width:568px) and (orientation:landscape){ .page { height: 67%; } } */ /* @media(max-width:1024px){ .page { height: 82%; } } @media(max-width:1024px) and (orientation:landscape){ .page { height: 73%; } } */ <style> .taxpubsectiontotal { margin-bottom: 100px; } @media(orientation:landscape) {     .pubmainpage .viewallpub {         padding: 0     }     .subitempopup .pubsubitem { ...