HTML/Javascript Button Click Counter

前端 未结 5 1219
南笙
南笙 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:48

    After looking at the code you're having typos, here is the updated code

    var clicks = 0; // should be var not int
        function clickME() {
            clicks += 1;
            document.getElementById("clicks").innerHTML = clicks; //getElementById() not getElementByID() Which you corrected in edit
     }
    

    Demo

    Note: Don't use in-built handlers, as .click() is javascript function try giving different name like clickME()

提交回复
热议问题