color inversion

 

 

code

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Color Inversion Example</title>

  <style>

    body {

      /* Your default styles here */

    }

 

    .inverted {

      filter: invert(100%);

    }

  </style>

</head>

<body>

  <button id="colorInversionBtn">Invert Colors</button>

 

  <!-- Your website content goes here -->

 

  <script>

    document.addEventListener('DOMContentLoaded', function () {

      const colorInversionBtn = document.getElementById('colorInversionBtn');

      let inverted = false;

 

      colorInversionBtn.addEventListener('click', function () {

        inverted = !inverted;

        applyColorInversion();

      });

 

      function applyColorInversion() {

        const body = document.body;

        if (inverted) {

          body.classList.add('inverted');

        } else {

          body.classList.remove('inverted');

        }

      }

    });

  </script>

</body>

</html>

 

© 2024 All Rights Reserved Terms of Use and Privacy Policy