Bonjour, je souhaiterais connaître si c'est possible de factoriser ce script? Merci d'avance.
(function() {
var dropDowm = document.querySelector('#dropdown'),
dropDownLink = document.querySelector('#dropdownLink'),
burgerIcon = document.querySelector('#burger-icon'),
navBar = document.querySelector('#navbar');
dropDowm.addEventListener('click', function() {
dropDowm.classList.toggle('active');
dropDownLink.classList.toggle('active');
});
burgerIcon.addEventListener('click', function() {
burgerIcon.classList.toggle('active');
navBar.classList.toggle('active');
dropDownLink.classList.toggle('active', false);
});
document.body.addEventListener('click', function() {
dropDowm.classList.toggle('active', false);
dropDownLink.classList.toggle('active', false);
burgerIcon.classList.toggle('active', false);
navBar.classList.toggle('active', false);
});
})();