Created
May 16, 2019 20:54
-
-
Save carlosmendozaweb/8602edc72bbd404cc36462f1fb7c3f49 to your computer and use it in GitHub Desktop.
Ejemplo de cómo recorrer array en Javascript
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
</head> | |
<body> | |
<button class="Btn" onclick="CambiarColores();">Btn 1</button> | |
<button class="Btn" onclick="CambiarColores();">Btn 2</button> | |
<button class="Btn" onclick="CambiarColores();">Btn 2</button> | |
<style> | |
.Btn{ | |
padding: 6px; | |
} | |
.Btn-Verde{ | |
background: green; | |
} | |
</style> | |
<script> | |
function CambiarColores() { | |
var Elementos = document.getElementsByClassName('Btn'); | |
for (var i = 0; i < Elementos.length; i++){ | |
Elementos[i].className = 'Btn Btn-Verde'; | |
} | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment