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

134
Views
Dividir un párrafo en una matriz y animar cada contenido de la matriz al hacer clic en el botón
<div id="container"> <button id="button">Click!</button> </div>

JS:

 const container = document.querySelector("#container"); const button = document.querySelector("#button"); button.addEventListener("click", () => { let para = document.createElement("p"); para.textContent = "Text message one. Text message two. Text message three."; let strText = para.textContent; let splitText = strText.split("."); for (let i=0; i<splitText.length;i++) { splitText.textContent += "<span>" + splitText[i] + "</span>"; } container.appendChild(splitText[i]); });

¡ESTOY ATASCADO! ¿Cómo puedo escribir mi código de tal manera que al hacer clic en el botón, los componentes de la matriz del párrafo se muestren (animados) en el div uno tras otro? Sé sobre la animación y la transición CSS, pero no sé cómo aplicarlo aquí.

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

0

¿Te refieres a algo como esto?

 const container = document.querySelector("#container"); const button = document.querySelector("#button"); let idx = 0; let sentnce = "Text message one. Text message two. Text message three."; let texts = sentnce.split(".").slice(0, -1); button.addEventListener("click", () => { if (idx < texts.length) { let p = document.createElement("p"); p.textContent = texts[idx]; container.appendChild(p); ++idx; } });
 <div id="container"> <button id="button">Click!</button> </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!