better script.js

This commit is contained in:
Grégory Lebreton 2025-05-15 15:36:35 +02:00
parent debd6e95a0
commit c9bfd3be98

View File

@ -1,4 +1,4 @@
// BULMA BURGER
// BULMA BURGER MENU
document.addEventListener('DOMContentLoaded', () => {
const burgers = Array.from(document.querySelectorAll('.navbar-burger'));
@ -11,19 +11,15 @@ document.addEventListener('DOMContentLoaded', () => {
targetMenu.classList.toggle('is-active');
});
});
});
// DARK MODE
document.addEventListener("DOMContentLoaded", function () {
const switchTheme = document.querySelector("#switch");
switchTheme.addEventListener("click", function () {
document.body.classList.toggle("dark-mode");
});
});
// CAROUSSEL
document.addEventListener("DOMContentLoaded", function () {
const track = document.querySelector('.carousel-track');
let index = 0;
@ -36,10 +32,9 @@ document.addEventListener("DOMContentLoaded", function () {
index = (index + 1) % document.querySelectorAll('.carousel-slide').length;
updateSlide();
}, 3000);
});
// BOUTON
document.addEventListener("DOMContentLoaded", function () {
// TRICKY BOUTON
const container = document.querySelector('.button-area');
const button = document.getElementById('trickyButton');
@ -53,19 +48,15 @@ document.addEventListener("DOMContentLoaded", function () {
button.style.left = `${randomX}px`;
button.style.top = `${randomY}px`;
});
});
// COMPTEUR
document.addEventListener("DOMContentLoaded", function () {
let compteur = 0;
document.getElementById("incrementer").addEventListener("click", () => {
let compteur = 0;
document.getElementById("incrementer").addEventListener("click", () => {
compteur++;
document.getElementById("compteur").textContent = compteur;
});
});
// ADDITION
document.addEventListener("DOMContentLoaded", function () {
document.getElementById("additionner").addEventListener("click", () => {
const a = parseFloat(document.getElementById('chiffre1').value);
const b = parseFloat(document.getElementById('chiffre2').value);