Javascript 如何使用HTML5输入类型范围中的值?
我的html页面中有一个值为0到0.5的滑块:Javascript 如何使用HTML5输入类型范围中的值?,javascript,html,css,python-3.x,Javascript,Html,Css,Python 3.x,我的html页面中有一个值为0到0.5的滑块: <fieldset> <label for="rangeVal">threshold</label> <input type ="range" max="0.5" min="0" oninput="document.getElementById('rangeValLabe
<fieldset>
<label for="rangeVal">threshold</label>
<input type ="range" max="0.5" min="0"
oninput="document.getElementById('rangeValLabel').innerHTML = this.value;"
step="0.01" name="rangeVal" id="rangeVal" value="0.1">
</input>
<em id="rangeValLabel" style="font-style: normal;"></em>
</fieldset>
我想做一些类似的事情:
如果我将光标移动到0.4,它将只显示值为0.4的单词
如果我将滑块的光标更改为0.3,它将显示值为0.3的单词
并且总是在同一个html页面中。。我需要在输入滑块变化时从中获取值;但是,我只想在释放鼠标后从滑块中获取值,而不是在鼠标向下拖动的过程中,然后根据输入滑块的值显示word。。
请帮忙?
<body>
<fieldset>
<label for="rangeVal">threshold</label>
<input type ="range" max="0.5" min="0"
oninput="showWord(this)"
step="0.01" name="rangeVal" id="rangeVal" value="0.1">
</input>
<em id="rangeValLabel" style="font-style: normal;"></em>
</fieldset>
<script>
function showWord (element) {
let wordList = {
0.03:"New",
0.04: "Green",
0.06: "Blue"
}
document.getElementById('rangeValLabel').innerHTML =
wordList[element.value];
}
</script>
</body>
门槛
函数showWord(元素){
让单词列表={
0.03:“新”,
0.04:“绿色”,
0.06:“蓝色”
}
document.getElementById('rangeValLabel')。innerHTML=
wordList[element.value];
}
请阅读。你已经向我们解释了你现在想要什么,但没有解释你在完成这件事上的实际问题是什么。您尝试了什么,遇到了哪些具体的错误或问题?这不是一个要求提供教程或类似内容的网站。
<body>
<fieldset>
<label for="rangeVal">threshold</label>
<input type ="range" max="0.5" min="0"
oninput="showWord(this)"
step="0.01" name="rangeVal" id="rangeVal" value="0.1">
</input>
<em id="rangeValLabel" style="font-style: normal;"></em>
</fieldset>
<script>
function showWord (element) {
let wordList = {
0.03:"New",
0.04: "Green",
0.06: "Blue"
}
document.getElementById('rangeValLabel').innerHTML =
wordList[element.value];
}
</script>
</body>