Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
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 answers
Answer question

0

Maybe you can add CSS Style on #res2

#res2 {
    display: flex;
    flex-direction: column;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!