Skip to content

Instantly share code, notes, and snippets.

@Aeonexe
Last active April 9, 2018 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aeonexe/5af4162a5151b86d142160eea9d0b02c to your computer and use it in GitHub Desktop.
Save Aeonexe/5af4162a5151b86d142160eea9d0b02c to your computer and use it in GitHub Desktop.
// Añade una clase revisando si una clase en otro elemento existe
// después hace una iteración para añadir la clase a cada elemento
var elemento = document.querySelector('.elemento').classList.contains('.una-clase');
var li = document.querySelectorAll('.nav li');
if( elemento ) {
for( var e = 0; e < li.length; e++ ) {
li[e].classList.add('.clase-a-añadir');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment