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

169
Views
¿Cómo mostrar el valor de entrada en la página en Javascript?

¿Cómo mostrar el valor de entrada en el sitio web? Ya intenté mostrarlo, pero cuando cambio el valor de la entrada, la pantalla sigue siendo la misma.

 const rangeInput = document.querySelector(".range"); const valueInp = document.querySelector(".value"); valueInp.innerHTML = rangeInput.value;
 <input type="range" min="1" max="100" value="1" step="1" class="range"/> <p class="value"></p>

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

0

Siempre que el elemento <p> para el valor siempre siga directamente después de su elemento de rango, la siguiente secuencia de comandos se encargará de cualquier cantidad de combinaciones de rango/valor:

 document.querySelectorAll(".range") .forEach(r=>r.addEventListener("input",update(r))); function update(r){ const ur= ()=>r.nextElementSibling.textContent=r.value; ur(); return ur; }
 <input type="range" min="1" max="100" value="40" step="1" class="range"/> <p></p> <input type="range" min="1" max="100" value="20" step="1" class="range"/> <p></p> <input type="range" min="1" max="100" value="30" step="1" class="range"/> <p></p>

about 4 years ago · Juan Pablo Isaza Report

0

Lo que hiciste pone en carga el valor de la entrada en el párrafo. Además, necesita un EventListener para rastrear los cambios de entrada, así:

 const rangeInput = document.querySelector(".range"); const valueInp = document.querySelector(".value"); valueInp.innerHTML = rangeInput.value; rangeInput.addEventListener("input", ()=>{ valueInp.innerHTML = rangeInput.value; })
 <input type="range" min="1" max="100" value="1" step="1" class="range"/> <p class="value"></p>

about 4 years ago · Juan Pablo Isaza Report

0

const rangeInput = document.querySelector(".range"); const valueInp = document.querySelector(".value"); rangeInput.addEventListener("input", () => { valueInp.textContent = rangeInput.value; }); valueInp.textContent = rangeInput.value;
 <input type="range" min="1" max="100" value="1" step="1" class="range"/> <p class="value"></p>```
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!