Last active
March 12, 2017 15:04
-
-
Save lmuzquiz/54667a2e7d7ae088b8436af2b3c2160e to your computer and use it in GitHub Desktop.
Example of querySelector method
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> | |
// querySelector regresa solamente la primer concordancia. | |
const MiConstante = document.querySelector('li.red'); | |
MiConstante.className = 'blue'; | |
</script> | |
<script> | |
// querySelectorAll regresa una lista de Nodos. | |
// Aunque estrictamente hablando se especifica seleccionar | |
// el segundo nodo, (con el num. 1) en este contexto en | |
// realidad es el tercer elemento de la lista que se | |
// termina seleccionado debido al query anterior. | |
const MiConstante2 = document.querySelectorAll('li.red'); | |
MiConstante2[1].className = 'blue'; | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment