Sayfanın Tamamında Koyu / Açık Renkli Temaya Geçme

Sayfanın Tamamında Koyu / Açık Renkli Temaya Geçme

<!DOCTYPE html>
<html data-bs-theme="light">

<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>Page Title</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link rel="stylesheet" href="./bootstrap-5.3.3-dist/css/bootstrap.css">
    <script src="./bootstrap-5.3.3-dist/js/bootstrap.js"></script>
</head>

<body>
    <div class="container">
        <button class="btn btn-outline-dark position-fixed" id="koyuTema" style="bottom: 10px;right: 300px;">Koyu Tema</button>
    </div>
</body>
<script>
    document.getElementById("koyuTema").addEventListener("click",function(){
        var html = document.getElementsByTagName("html")[0];
        var buton = document.getElementById("koyuTema");
        // alert();
        if(html.getAttributeNode("data-bs-theme").value == "light"){
            html.setAttribute("data-bs-theme","dark");
            buton.classList.remove("btn-outline-dark");
            buton.classList.add("btn-outline-light");
        }
        else{
            html.setAttribute("data-bs-theme","light");
            buton.classList.remove("btn-outline-light");
            buton.classList.add("btn-outline-dark");
        }
    });
</script>
</html>

 

 

Yorumunuzu Ekleyin
Yükleniyor...
    Yükleniyor...