Created
January 23, 2022 08:28
-
-
Save damiancastelao/ef6c188445dde2ecd61003ed22a19ba3 to your computer and use it in GitHub Desktop.
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
<html> | |
<body> | |
<div id="principal"></div> | |
</body> | |
<script> | |
for (let contador = 0; contador < 10; contador++) { | |
//Recoges el div al que le quieres añadir otro div repetidas veces | |
divPrincipal = document.getElementById("principal"); | |
// Creas un div, con el id | |
auxDiv=document.createElement('div'); auxDiv.id = "posicion" + contador; | |
//Se lo añades al principal | |
divPrincipal.appendChild(auxDiv); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Añade al div "principal" 10 div, que tiene cada uno su propia id.