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

Magento

php D:\xampp\htdocs\veng_portal\bin\magento cache:clean php D:\xampp\htdocs\veng_portal\bin\magento cache:flush php D:\xampp\htdocs\veng_portal\bin\magento setup:upgrade php D:\xampp\htdocs\veng_portal\bin\magento indexer:reindex php D:\xampp\htdocs\veng_portal\bin\magento setup:static-content:deploy nb_NO http://localhost/veng_portal/admin username : vp_admin password: pass@12345 Remove pub/static Remove var/cache Remove var/composer_home Remove var/generation Remove var/page_cache Remove var/view_preprocessed run php D:\xampp\htdocs\veng_portal\bin\magento setup:static-content:deploy Run below command to reindex the data in magento     - C:\xampp\php>php C:\xampp\htdocs\magento2\bin\magento indexer:reindex To update static-content     -D:\xampp\php>php D:\xampp\htdocs\veng_portal\bin\magento setup:static-content:deploy nb_NO http://codepen.io/zeinab92/pen/JYKyBx UPDATE `magentodemo`.`admin_user` SET `password`='b5641701...

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...