HTML/Javascript Button Click Counter

前端 未结 5 1231
南笙
南笙 2020-12-09 10:24

I have done something similar to this before, and I know this is really close. I\'m just trying to make it so that my button increments the javascript variable, and the func

5条回答
  •  青春惊慌失措
    2020-12-09 10:55

    Use var instead of int for your 'clicks' variable generation and 'onClick' instead of 'click' as your function name:

    
    
        Space Clicker
    
    
    
        
        
        

    Clicks: 0

    In JavaScript variables are declared with the 'var' tag, there are no tags like int, bool, string... to declare variables. You can get the type of an variable with 'typeof(yourvariable)', more support about this you find on Google.

    And the name 'click' is reserved by JavaScript for functionnames so you have to use anything else.

提交回复
热议问题