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

229
Views
función appendChild que podría llamarse varias veces y crear varios elementos con contenido en ella

¿Cómo se supone que debo convertir este código secundario adjunto para que funcione, de modo que pueda hacer que mi código sea más legible y más corto? ¿También sería posible que uno de esos hijos agregue otro hijo, también creado con esta función?

 let infoDiv = document.createElement("div"); infoDiv.classList.add("fullEventInfo"); classes.appendChild(infoDiv); let titleTypeDiv = document.createElement("div"); titleTypeDiv.classList.add("titleType"); infoDiv.appendChild(titleTypeDiv);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Utilizar este:

 function createElement(type, props, ...children) { const elem = document.createElement(type); if(props) Object.assign(elem, props); for(let child of children) { if(typeof child === "string") elem.appendChild(document.createTextNode(child)) else elem.appendChild(child) } return elem; }

Asi que:

 let elem = createElement("div", { className: "test" }, createElement("p", {}, "hello world !!!"));

Esto se traduce como:

 <div class="test"> <p>hello world !!!</p> </div>
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!