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

138
Views
¿Cómo hacer que el usuario haga clic en números en divs en orden ascendente?

Necesito crear un juego con JS puro. Genero 16 números en 16 divs en un orden aleatorio y se supone que el usuario debe hacer clic en esos números en 10 segundos en orden ascendente si el usuario falla, el juego termina.

¿Cómo asegurarse de que el siguiente clic del usuario div contenga el número 2?

 var divs = document.querySelectorAll("div"); function generisi() { let niz = new Set() var i = 0; while (niz.size < 16) { niz.add(Math.floor(Math.random() * 16) + 1); console.log(niz); } niz = Array.from(niz); for (var j = 0; j < divs.length; j++) { divs[j].innerHTML = '<p class="broj">' + parseInt(niz[j]) + '</p>'; } } for (var i = 0; i < divs.length; i++) divs[i].addEventListener("click", function() { for (var j = 0; j < divs.length; j++) { if (divs[j].getElementsByTagName("p")[0].innerText == 1) { divs[j].getElementsByTagName("p")[0].innerText = "" } } })

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!