简体   繁体   中英

How can I increase or decrease a value for <input type="range" min="1" max="30" value="15" step="1"> in JavaScript? Span for Value in html is made

Image of my Pass Generator

If I move the pointer to the right or left the Value "00" doesn't do anything. It doesn't increase and decrease.

Hope for some help.

I've tried it with

const updateSlider = () => {
  document.querySelector(".pass-length span").innerText = lengthSlider.value;
  generatePassword();
  updatePassIndicator();
}
updateSlider();

but it doesn't work.

This should update the label. I dont have your code, so I cant fit it to your case but making it work for you should not be too hard.

 const slider = document.getElementById("slider"); const sliderValue = document.getElementById("slider-value"); slider.addEventListener("input", (e) => { sliderValue.innerHTML = e.target.value; });
 <input type="range" min="1" max="30" default="15" step="1" id="slider"> <p id="slider-value">Slider Value: 00</p>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM