Help w/ a project

if you look at the code, I am trying to make the <progress> tag increase by 1 each time, but for some reason, I couldn’t get it right and it wouldn’t increase.

my code:

<button class = "btn btn-default" id = "a1">Add</button>
<progress id = "p1" value = "10" max  = "100"></progress>
<script>
  var num1 = $("#p1").val();
$("#a1").on("click",function(){
  num1++;
});</script>```

So you want to increase the value of the progress element’s value attribute by 1 each time the Add button is clicked? If so, then you must first obtain the current value of the progress element’s value attribute and assign it to a variable (i.e. num1) and then increment num1 by 1, and finally assign the new value of num back to the progress element’s value attribute.

In your current solution, you assign num1 the value outside the click event. Do this inside the click event and then after your num1++ line use the val function to assign num1 back to the progress element.

1 Like

okay, I tried that, but it still wouldn’t work. I was using codepen.

I did this, and it didn’t work:

  num1++;
  var num1 = $("#p1").val();

});```

oops! I did fixed it, and it is pretty stubborn. it didn’t work.
:frowning:

here:
https://codepen.io/Hackdragon/pen/eLzoOW

that returned an error