I trie to get every the previouselementSibling of a div, but stil have problems with that. There is a way to get this?
garrafinhas.forEach((garrafa,indice)=>{
garrafa.addEventListener('click',()=>{
if(garrafa.classList.contains('garrafinha') ){
garrafa.classList.remove('garrafinha')
}
else
{
while(garrafa.previousElementSibling !== 0){
garrafa = garrafa.previousElementSibling;
garrafa.classList.add('garrafinha')
garrafa.classList.add('garrafinha')
}
}
console.log(indice, garrafinhas.length)
})
})