Created
March 8, 2021 22:11
-
-
Save thyagofranca/26e1cc7b04286068c6b70f04c064d184 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const toggleType = document.querySelectorAll('#toggle-type'); | |
const typeName = document.querySelector('#type-name'); | |
const iconsTigela = document.querySelectorAll('#tigela'); | |
const iconsCopo = document.querySelectorAll('#copo'); | |
const imagesTigela = document.querySelectorAll("#img-tigela") | |
const imagesCopo = document.querySelectorAll("#img-taca") | |
const handleToggleType = (e) => { | |
if (e.target.checked) { | |
iconsTigela.forEach(img => img.classList.remove('ativa')) | |
iconsCopo.forEach(img => img.classList.add('ativa')) | |
imagesTigela.forEach(img => img.classList.add('hidden')) | |
imagesCopo.forEach(img => img.classList.remove('hidden')) | |
typeName.innerText = 'Smoothies'; | |
} else { | |
iconsCopo.forEach(img => img.classList.remove('ativa')) | |
iconsTigela.forEach(img => img.classList.add('ativa')) | |
imagesCopo.forEach(img => img.classList.add('hidden')) | |
imagesTigela.forEach(img => img.classList.remove('hidden')) | |
typeName.innerText = 'Bowls'; | |
} | |
} | |
toggleType.forEach(toggle => toggle.addEventListener('change', handleToggleType)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment