Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to add and/or subtract numbers using html and js to make a buy and sell system?

I want to make a system when you click:

{before click = Coins: 0}

{after click = Coins: 1}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

use js.

add(x);
remove(x);

and I want to make shops:

function e() {
var demo = document.getElementById('demo').innerHTML=add(1);
}

and

<button onclick="e()">get 1 coin</button>

to make this:

function e() {
  var demo = document.getElementById('demo').innerHTML = "Coins: 1";
}
<!DOCTYPE>
<html>

<body>
  <p id='demo'>Coins: 0</p>
  <button onclick="e()">get 1 coin(plz edit this code)</button>
</body>

</html>

>Solution :

<html>
<body>
<p id='demo'>Coins: 0</p>
<!-- get web script form javascript -->
<script>
let counter =0;
function e() {
counter++;
  var demo = document.getElementById('demo').innerHTML=`Coins: ${counter}`;
}
</script>
<button onclick="e()">get 1 coin(plz edit this code)</button>
</body>
</html>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading