如果您在输入/文本中键入任何内容,则我有2个输入,如在代码中看到的那样,它在范围内显示得很好,但是反过来这是我的问题 对于接受任何答案的问题,我也持完全不同的态度
代码段:
private void removeAnchorNode(AnchorNode nodeToremove) {
//Remove an anchor node
if (nodeToremove != null) {
arFragment.getArSceneView().getScene().removeChild(nodeToremove);
anchorNodeList.remove(nodeToremove);
nodeToremove.getAnchor().detach();
nodeToremove.setParent(null);
nodeToremove = null;
} else {
//Handle error case here
}
}
var city = document.getElementById('city')
var cityrepeat = document.getElementById('cityrepeat')
var state = document.getElementById('state')
var staterepeat = document.getElementById('staterepeat')
function setCity() {
cityrepeat.value = city.value
}
function setd() {
city.value = cityrepeat.value
}
function setState() {
staterepeat.value = state.value
}
答案 0 :(得分:2)
使用onKeyUp="setd()"
代替onchange="setd()"
<input id="cityrepeat" type="range" min="1" max="100" onchange="setd()"/>
甚至更好: 为了使值更新“实时”,您可以执行以下操作:
html中的:
<input id="cityrepeat" type="range" min="1" max="100" onmousedown="updating=true;setd()" onmouseup="updating=false"/>
在您的脚本中:
var updating = false
function setd() {
city.value = cityrepeat.value
if (updating){
requestAnimationFrame(setd)
}
}
var city = document.getElementById('city')
var cityrepeat = document.getElementById('cityrepeat')
var state = document.getElementById('state')
var staterepeat = document.getElementById('staterepeat')
var updating = false
function setCity() {
cityrepeat.value = city.value
}
function setd() {
city.value = cityrepeat.value
if (updating){
requestAnimationFrame(setd)
}
}
function setState() {
staterepeat.value = state.value
}
City
<input id="city" type="text" onKeyUp="setCity()" size=5/><br>
State
<input id="state" type="text" onKeyUp="setState()" size=5/><br>
City repeat
<input id="cityrepeat" type="range" min="1" max="100" onmousedown="updating=true;setd()" onmouseup="updating=false"/><br>
State repeat
<input id="staterepeat" type="range"/>
答案 1 :(得分:1)
尝试使用onChange
代替滑块上的onKeyUp
。
<input id="cityrepeat" type="range" min="1" max="100"onChange="setd()"/></br>