Here are my comments.
1. As suggested by other member, you need to update the code to hook up the button click event.
2.
getElementsByClassName
return array of object, assuming you want the code to access the first button, then the code should look like document.getElementsByClassName("btn")[0];
3. The button initial text value is 0 on page load, so on button click, the counter should show 1, either move the counter++; to the top or start the counter from 1
4. You can also update the button to include an
id
attribute i and the JavaScript to use
getElementById
method
<div class="button">
<button type="button" class="btn" id="btn" onclick="incrementer()">0</button>
</div>
var buttonTarget = document.getElementsByClassName("btn")[0];
var counter = 1;
function incrementer(){
buttonTarget.innerHTML = counter.toString();
counter++;
return counter;
}
Document.getElementsByClassName() | MDN[
^]