i am trying to code two button here , base number is 0, the number can be +/- when i click which one number. Now my problem is number only two answer:1,-1.
i want,
click + btn 3 times, the number should be 0 to 3 and
click - btn 2 times, the number should be 1.
i think my code is not clear and very very wrong.
<!DOCTYPE html>
<html>
<head>
<title>ABCDEFG</title>
</head>
<body>
<input id="btnPlus" type="button" value="+" onclick="numberPlus()">
<input id="btnMinus=" type="button" value="-" onclick="numberMinus()">
<p id="number">0</p>
<script>
function numberPlus() {
var y;
var x;
y = 0;
x = ++y;
document.getElementById("number").innerHTML= x;
}
function numberMinus() {
var y;
var x;
y = 0;
x = --y;
document.getElementById("number").innerHTML= x;
}
</script>
</body>
</html>