<body>
<h1>Inversion</h1>
<p><button type="button"> Inverser</button></p>
</body>
let bouton = document.querySelector("button")
bouton.addEventListener("click", inverser)
function inverser() {
let corps = document.querySelector("body");
if (corps.style.color == "white") {
corps.style.color = "black";
} else {
corps.style.color = "white";
}
if (corps.style.backgroundColor == "black") {
corps.style.backgroundColor = "white";
} else {
corps.style.backgroundColor = "black";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.