How to add 1 to a javascript variable by clicking a button?

后端 未结 3 2068
孤独总比滥情好
孤独总比滥情好 2021-01-29 06:14

I have very little experience with writing javascript and I need help desperately. I need to make so that when a button is clicked the score goes up by one similar to how the co

3条回答
  •  渐次进展
    2021-01-29 06:30

    Your code already works. Here's a demo that demonstrates your code in action.

    I have added a function to display the click count:

    function updateClickCount() {
        document.getElementById("clickCount").innerHTML = clicks;
    }
    

提交回复
热议问题