<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="\bootstrap5\css\bootstrap.css">
<link rel="stylesheet" href="css\main.css" id="theme1">
<link rel="shortcut icon" href="\resource\img\2379396.svg" type="image/x-icon">
<link rel="stylesheet" href="css/fontello.css">
<title>Закрепи Знания</title>
</head>
<body>
<button id="theme" type="button" class="btn btn-primary active" data-toggle="button" autocomplete="off" aria-pressed="true">СМЕНИТЬ ТЕМУ</button>
<script src="\bootstrap5\js\bootstrap.bundle.min.js"></script>
<script src="\js\main.js"></script>
<script src="\main.js"></script>
</body>
</html>
let switchMode = document.getElementById("theme");
switchMode.onclick = function() {
let theme = document.getElementById("theme1");
if (theme.getAttribute("href" == "css\main.css"))
{
theme.href = "css\main_dark.css";
console.log(1);
}
else
{
theme.href = "css\main.css";
console.log(0);
}
}
<link rel="stylesheet" href="css/main.css" id="theme1">
let switchMode = document.getElementById("theme");
switchMode.onclick = function() {
let theme = document.getElementById("theme1");
if (theme.getAttribute("href") === "css/main.css") {
theme.setAttribute("href", "css/main_dark.css");
console.log(1);
} else {
theme.setAttribute("href", "css/main.css");
console.log(0);
}
}
<link rel="stylesheet" href="css/main.css" id="theme1">
const switchMode = document.querySelector("#theme");
const theme = document.querySelector("#theme1")
switchMode.addEventListener('click', () => {
theme.href === 'css/main.css'
? theme.href = 'css/main_dark.css'
: theme.href = 'css/main.css'
})