vendredi 23 juillet 2021

Javascript check if target contains class with switch-case instead of if else

Currently I have a code structure:

if(target.classList.contains('animate-heading')){

}else if(target.classList.contains('animate-text')){

}else if(target.classList.contains('animate-buttons')){

}else if(target.classList.contains('image-rotating-animation')){

}else if(target.classList.contains('plans-heading-animation')){

}else if(target.classList.contains('plans-animation')){

}else if(target.classList.contains('animate-masonry')){

}

which I want to replace with switch-case statements, is it possible to do it? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire