我想从外部获取价值,以取得进步。但这不起作用。
<form oninput="y.value=parseInt(height.value)">
Yaşınız:<input type="text" name="age"><br>
Boyunuz: <input type="range" name="height" min="150" max="230">
<output onchange="bar.value=parseInt(y.value)" name="y"></output>cm <br>
<progress name="bar" max="230"></progress>
</form>
答案 0 :(得分:0)
也许你是这个意思?
document.querySelector("form").addEventListener("input", function() {
var val = parseInt(this.height.value);
this.y.value = val;
document.getElementById("bar").value = val;
});
var height = document.getElementById("height").value;
document.getElementById("y").value = height
document.getElementById("bar").value = height
<form>
Yaşınız:<input type="text" name="age"><br/>
Boyunuz: <input type="range" name="height" id="height" min="150" max="230">
<output name="y" id="y"></output>cm<br/>
<progress name="bar" id="bar" max="230"></progress>
</form>