递增0.1 javascript
function img1_min_w(){
var x = document.getElementById("val_img1_l").value++;
}

<input type="button" onclick="img1_min_w()" value="+">
<output id="val_img1_l">1</output>
<p> i want incrementing by 0.1;</p>
&#13;
答案 0 :(得分:2)
可能
var val = parseFloat(document.getElementById("val_img1_l").innerHTML);
document.getElementById("val_img1_l").innerHTML = parseFloat(val + 0.1).toFixed(1);
// for 1 decimal value... change number for more
答案 1 :(得分:1)
function addValue() {
const ADD_VALUE = 0.1;
let element = document.getElementById("target");
let value = parseFloat(element.innerHTML);
element.innerHTML = parseFloat(value + ADD_VALUE).toFixed(1);
}
button {
height: 32px;
width: 64px;
background-color: red;
}
<div>
<button onClick='addValue();'>Add</button>
</div>
<div id="target">1</div>
答案 2 :(得分:0)
document.getElementById("val_img1_l").value += 0.1;
编辑:这绝对是错误的。见评论:))