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 .
.appendTo() es un método jQuery , parece que está usando javascript simple, tal vez quiera usarappend o appendChild