document.querySelectorAll('.myStyle__switch input').forEach(function(checkbox) { checkbox.addEventListener('change', function() { // Force reflow of the label to ensure proper positioning const label = checkbox.nextElementSibling; label.style.display = 'none'; void label.offsetWidth; label.style.display = ''; }); });