Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
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 Respostas
Responde à pergunta

0

Maybe you can add CSS Style on #res2

#res2 {
    display: flex;
    flex-direction: column;
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda