Change input
to see the value beeing printed in the console
.
replace this
with range
.
let n;
let range = document.getElementById('range');
range.min = '0';
range.max = '100';
range.step = '1';
range.value = '20';
range.addEventListener('input', () => {
if (range.value > 0 && range.value < 100) {
n = range.value;
}
console.log(n);
});
<input id="range" type="range">
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…