我希望按钮(+)增加0.3和( - )偏差0.3,范围
value_to_record
function move1(){
var x1l = document.getElementById("imjv1l").value;
document.getElementById('val_img1_l').value=x1l;
}
答案 0 :(得分:2)
function increment(plusMinus) {
var x1l = parseFloat(document.getElementById("imjv1l").value);
x1l += plusMinus * 0.3;
x1l = x1l.toFixed(2)
document.getElementById("imjv1l").value=x1l;
document.getElementById("val_img1_l").value=x1l;
}
function move1(){
var x1l = document.getElementById("imjv1l").value;
document.getElementById('val_img1_l').value=x1l;
}

<input type="range" min="0" max="100" value="50" step="0.1" style="width:100%;" oninput="move1(this.value)" id="imjv1l">
<output id="val_img1_l">50</output><br>
<input type="button" value="+" onclick="increment(1)"><input type="button" value="-" onclick="increment(-1)">
&#13;
5
答案 1 :(得分:0)
function move1(){
var x1l = Number(document.getElementById("imjv1l").value);
x1l += 0.3;
document.getElementById('val_img1_l').value=x1l;
}
function applyDelta(shouldIncrease){
var delta = (shouldIncrease) ? 0.3 : -0.3;
document.getElementById("imjv1l").value = Number(document.getElementById("imjv1l").value) + delta;
move1();
}
<input type="range" min="0" max="100" value="50" step="0.3" style="width:100%;" oninput="move1(this.value)" id="imjv1l">
<output id="val_img1_l">50</output><br>
<input type="button" value="+" onclick="applyDelta(true)"><input type="button" value="-" onclick="applyDelta(false)">