function increase( y) {
var x = document.getElementById("result");
var before= x.value;
x.innerHTML= Number(before) + Number(y);
}
<b>Rp. <b id='result'>1240000</b> </b>
<button type="button" onclick="increase(80000)"> add </button>
function increase( y) {
var x = document.getElementById("result");
var before= x.value;
x.innerHTML= Number(before) + Number(y);
}
<b>Rp. <b id='result'>1240000</b> </b>
<button type="button" onclick="increase(80000)"> add </button>
You have to use innerHTML
to get the value of <b>
.
function increase( y) {
var x = document.getElementById("result");
x.innerHTML= parseInt(x.innerHTML) + parseInt(y);
}
<b>Rp. <b id="result">1240000</b> </b>
<button type="button" onclick="increase(80000)"> add </button>