Last active
March 13, 2017 00:50
-
-
Save lmuzquiz/824946e19b58ff49edff3170f611d42c to your computer and use it in GitHub Desktop.
Utilizando el método getElementsByTagName
This file contains 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
<script> | |
// Encontrar los elementos <li> y ponerlos en una variable | |
var elements = document.getElementsByTagName('li'); | |
if (elements.length > 0) { // Si más de uno es encontrado | |
var el = elements[3]; // Selecciona el cuarto elemento de la colección | |
el.className = 'cool'; // Cambia el valor del atributo clase | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment