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

89
Views
Crear elemento dentro de otro basado en id.

ahora mismo tengo este código para dibujar algunos divs (según alguna lógica, tendré padres e hijos.

 array.forEach(async (a, b) => { var currentDiv = 0; let divHtml; if (b === 0) { //This should be the first parent divHtml = document.createElement('div'); divHtml.id = 'someID' + currentDiv; } else if (previousDiv != currentDiv) { // This should be used for next parents based on the previousDiv & currentDiv logic divHtml = document.createElement('div'); divHtml.id = 'someID' + currentDiv; } else { // This should be used only for childs. I want to create another div but inside the parent that I have stored into currentDiv. divHtml = document.getElementById('someID' + currentDiv); divHtml.id = 'someChildID' + currentDiv; } // Some more code below but what it's important is this (I continue using the divHtml in a lot of places on my code): divHtml.setAttribute('someData', someDataAttribute); });

Entonces, mi pregunta es: si hay una manera de obtener parentDiv y dibujar dentro de los elementos X childs y ¿cómo puedo hacerlo? Probé con esto:

 divHtml = document.createElement('div').appendTo($('#someID' + currentDiv));

Pero recibo .appendTo() no es un mensaje de error de función .

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.appendTo() es un método jQuery , parece que está usando javascript simple, tal vez quiera usarappend o appendChild

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!