Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
I´m trying to create elements dinamically on javascript and inserting them on my HTML, but the tag <br> just don´t work

I´m working on a for that create HTML elements than insert them into my page dinamically.

for (let i = 0; i < 26; i++) {
    var res2 = document.getElementById("res2")

    var divCriada = document.createElement("div")
    divCriada.className = "divname"
    divCriada.innerHTML = "abc"

    res2.appendChild(divCriada)
    
    var input   = document.createElement("input")
    input.className = "input"

    let divInserida= document.getElementsByClassName("divname")
    divInserida[i].appendChild(input)

    var br = document.createElement("br")
    res2.appendChild(br)
}

Notice that, the code is doing exactly what it was made for:

https://i.stack.imgur.com/iI5lk.png

All 26 divs are being created correctly, but the line break just don´t work! you can see right ahead!

https://i.stack.imgur.com/974lD.png

I don´t know what to do, i don´t find any answer anywhere =(

i´m new to this world, maybe it could be a gross mistake by me, but if you find it i would aprecciate a lot if you explain what you did and why mine is not working.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Maybe you can add CSS Style on #res2

#res2 {
    display: flex;
    flex-direction: column;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda