如何将我的范围滑块最大值设置为 windows 宽度 / 10
How can I set my range sliders max to be the windows width / 10
如何使范围滑块最大为 windows 宽度 / 10,如下所示:
<input type="range" min="0" max="100vw/10"
以前我的代码中有:
<input type="range" id="rangeSlider" min="0" max="100">
<p id="p"></p>
<button id="getValueButton>Get Value</button>
let rangeSlider = document.querySelector("#rangeSlider");
let p = document.querySelector("#p");
let getValueButton = document.querySelector("#getValueButton");
getValueButton.onclick = function() {
p.innerHTML = `${rangeSlider.value * 12.5} pixels from the left`;
}
let rangeSlider = document.querySelector("#rangeSlider");
let p = document.querySelector("#p");
let getValueButton = document.querySelector("#getValueButton");
getValueButton.onclick = function() {
p.innerHTML = `${rangeSlider.value * 12.5} pixels from the left`;
}
<input type="range" id="rangeSlider" min="0" max="100">
<p id="p"></p>
<button id="getValueButton">Get Value</button>
您可以这样设置最大值:
document.getElementById('rangeSlider').max = window.screen.width / 10
如何使范围滑块最大为 windows 宽度 / 10,如下所示:
<input type="range" min="0" max="100vw/10"
以前我的代码中有:
<input type="range" id="rangeSlider" min="0" max="100">
<p id="p"></p>
<button id="getValueButton>Get Value</button>
let rangeSlider = document.querySelector("#rangeSlider");
let p = document.querySelector("#p");
let getValueButton = document.querySelector("#getValueButton");
getValueButton.onclick = function() {
p.innerHTML = `${rangeSlider.value * 12.5} pixels from the left`;
}
let rangeSlider = document.querySelector("#rangeSlider");
let p = document.querySelector("#p");
let getValueButton = document.querySelector("#getValueButton");
getValueButton.onclick = function() {
p.innerHTML = `${rangeSlider.value * 12.5} pixels from the left`;
}
<input type="range" id="rangeSlider" min="0" max="100">
<p id="p"></p>
<button id="getValueButton">Get Value</button>
您可以这样设置最大值:
document.getElementById('rangeSlider').max = window.screen.width / 10