html - How to reset a counter back to 0 with a button in javascript? -
i have counter in javascript right , button adds 1 value counter, have far:
var counter = 0; var = 0; var add = function(valuetoadd){ += valuetoadd; document.getelementbyid('value').innerhtml = a; }
value $<span id="value">0</span> <button width="500" height="500" id = add class="button button1" onclick="javascript:add(1)">add value</button>
i need button reset counter 0 appreciated.
add button, reset function , set values "0" shown in code below:
<button width="500" height="500" id ="reset" class="button button1" onclick="javascript:reset()">reset value</button> <script type="text/javascript"> var reset= function(){ = 0; document.getelementbyid('value').innerhtml = a; } </script>
btw declared var count = 0 in code (question) not using (apparently).