jQuery - Increase the value of a counter when a button is clicked

前端 未结 7 1374
轻奢々
轻奢々 2020-11-27 02:50

I\'m making a system where a user clicks a button and their score increases. There is a counter which I would like to increase the value of using jQuery (so that the page do

7条回答
  •  被撕碎了的回忆
    2020-11-27 03:29

    You are trying to set "++" on a jQuery element!

    YOu could declare a js variable

    var counter = 0;
    

    and in jQuery code do:

    $("#counter").html(counter++);
    

提交回复
热议问题