[英]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.如果我将指针向右或向左移动,值“00”不会执行任何操作。 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.这应该会更新 label。我没有你的代码,所以我不能让它适合你的情况,但让它为你工作应该不会太难。
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.