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

Angular Js

http://weblogs.asp.net/dwahlin/video-tutorial-angularjs-fundamentals-in-60-ish-minutes https://github.com/angular/angular.js/wiki/JsFiddle-Examples http://www.cheatography.com/proloser/cheat-sheets/angularjs/pdf/ https://github.com/jmcunningham/AngularJS-Learning