I try to make next code:
if(parseInt(e.target.value) === 1){
e.target.nextSibling.childNodes.forEach(element => {
element.classList.add('disable')
});
}
else if(parseInt(e.target.value) === 2){
e.target.nextSibling.childNodes.forEach(element,index => {
index === 0 ?
element.classList.remove('disable')
:element.classList.add('disable')
});
}
and in second condition it throw me error 'element' is not defined
but in first it works fine. But I cant understand why if statment make my element is undefined?
Aucun commentaire:
Enregistrer un commentaire