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

188
Views
¿Cómo hago para que un número se actualice y se muestre en vivo en HTML consecutivamente?

Hasta ahora estoy atrapado aquí. Sigo recibiendo NAN como resultado. Intenté comenzar con un párrafo y obtener el número 0 pero devuelve "no se pueden leer las propiedades de nulo (leyendo 'addEventListener')"

 <html> <style> </style> <body> <p id="result" value=0> 0 </p> <button id="func">RUN IT</button> <script> document.getElementById("func").addEventListener("click", () => { var n = document.getElementById("result"); console.log(result); if (n != 10) { n++; document.getElementById("result").innerHtml = n; }}); </script> </body> </html>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Si entiendo su problema correctamente, desea agregar 10 al resultado cada vez que se hace clic en el botón.

 let result = document.querySelector('#result'); document.querySelector('#func').addEventListener('click', (e) => { if (result.textContent != 10) { result.textContent++ } })
 <p id="result">0</p> <button id="func">RUN IT</button>

Espero haber podido ayudar

about 4 years ago · Juan Pablo Isaza Report

0

 document.getElementById("func").addEventListener("click", () => { var n_isADomElement = document.getElementById("result"); let v = +n_isADomElement.innerText if (v != 10) { v++; n_isADomElement.innerText = v; } });
 <html> <style> </style> <body> <p id="result" value=0> 0 </p> <button id="func">RUN IT</button> </body> </html>

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!