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

226
Views
El botón no está conectado en bucle, pero el último es
function createTimer(countdownObject) { let id = countdownObject.Id let removeClass = "inline remove" //(isRemoveButtonsEnabled && "inline remove") || "inline remove hidden" document.getElementById("countdownList").innerHTML += ` <dt id = "` + id + `" class = "countdown"> <h2 id = "` + id + `-title" class="title">Example Timer</h2> <h3 id = "` + id + `-daysNum" class = "time inline"></h3> <h3 id = "` + id + `-daysDesc" class = "time description inline">days</h3> <h3 id = "` + id + `-hoursNum" class = "time inline"></h3> <h3 id = "` + id + `-hoursDesc" class = "time description inline">hours</h3> <h3 id = "` + id + `-minsNum" class = "time inline"></h3> <h3 id = "` + id + `-minsDesc" class = "time description inline">minutes</h3> <h3 id = "` + id + `-secsNum" class = "time inline"></h3> <h3 id = "` + id + `-secsDesc" class = "time description inline">seconds</h3> <br> <input type="button" value="Delete" id = "` + id + `-remove" class="` + removeClass + `"></button> </dt> ` const removeButton = document.getElementById(id + "-remove") console.log(removeButton) updateTimer(countdownObject) removeButton.onclick = function () { removeTimer(id) }() } function removeTimer(id) { for (let i = 0; i < countdowns.length; i++) { if (countdowns[i].Id == id) { countdowns.splice(i, 1) } } document.getElementById(id).remove() console.log(countdowns) saveCountdowns() }

Estoy tratando de crear este widget de cuenta regresiva. Estoy ejecutando esta función en un bucle for básico e ingresando un objeto de countdownObject con las teclas Name , End e Id . Hay un problema que solo permite que funcione uno de los botones a la vez (generalmente el último creado) y no tengo idea de por qué. La función removeTimer funciona perfectamente, es solo un problema de que todos los botones no se conectan al evento onclick .

Visual

about 4 years ago · Juan Pablo Isaza
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!