而不是id="second"
所在的span标记,我想要一个输入文本字段,其中显示的值就像现在显示的那样但是我可以编辑它。换句话说,我希望能够 edit the value that shows up in this picture。怎么办呢?
<html>
<head>
<style>
.slider {
writing-mode: bt-lr; /* IE */
-webkit-appearance: slider-vertical; /* WebKit */
width: 90px;
height: 550px;
padding: 0 5px;
}
</style>
<script>
var slider = document.getElementById("first");
var output = document.getElementById("second");
output.innerHTML = slider.value;
slider.oninput = function() {
output.innerHTML = this.value;
}
</script>
</head>
<body>
<input type="range" min="0" max="1500" value="0" class="slider" id="first"/>
<p>Value(mm): <span id="second"></span></p>
</body>
</html>
答案 0 :(得分:0)
尝试input
文字。此外,您必须使用value
代替innerHTML
:
var slider = document.getElementById("first");
var output = document.getElementById("second");
output.value = slider.value;
slider.oninput = function() {
output.value = this.value;
}
&#13;
<input type="range" min="0" max="1500" value="0" class="slider" id="first"/>
<p>Value(mm): <input type="text" id="second" /></p>
&#13;