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

79
Views
¿Cómo consigo el Rolls Royce?

Al desplazarme hacia adelante o hacia atrás, quiero recuperar información relevante de la matriz. ¿Por qué el valor de "página" no es válido en document.getElementById("car").innerHTML = (cars[page][0]);

 <!DOCTYPE html> <html lang='sv-se'> <head> <title>Page Scroll</title> <meta charset='utf-8'> <script> const cars = [ [ 'Ford' ],[ 'Rolls Royce' ],[ 'Bentley' ],[ 'Volvo' ],]; </script> <script>var page = 0;let length = cars.length;</script> </head> <body style='text-align:center;'> <h1 id='page'>0</h1> <h2 id='car'>Car</h2> <button type='button' onclick='prevPage()'> PREV </button> Scroll with the arrows <button type='button' onclick='newPage()'> NEXT </button> <p>The length of the data file: <a id='len'>0</a></p> <script> function newPage() { if (page > length - 2) { page = 0; } else { page += 1; } document.getElementById('page').innerHTML = page; }; function prevPage() { if (page < 1) { page = length - 1; } else { page -= 1; } document.getElementById('page').innerHTML = page; }; </script> <script> document.getElementById('car').innerHTML = (cars[page][0]); document.getElementById('len').innerHTML = length; </script> </body></html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

document.getElementById('car').innerHTML = (cars[page][0]); solo se ejecuta una vez, al comienzo de la carga de la página. Agréguelo a su código en nextPage y prevPage

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!