Struggling to get results for counting how many people i greeted//anyone please..need help!


   <script type="text/javascript">
       var clicks = 0++;
       function click() {
           clicks += 1;
           document.getElementById("clicks").innerHTML = clicks;
       <button type="button" onClick="click()">Click me</button>
       <p>Clicks: <a id="clicks">0</a></p>


Instead of

var clicks = 0++;


var clicks = 0;

All you need just initialize variable. 0++ is wrong.


onclick should be all lowercase according to documentation


thanks guys..but still not working..i think it should increment the moment I greet a person..and when I click on "clickme"it doesn't increment


click seems to be a reserved word, when i change click to x, it works fine (code bin)


hooray!!it worked!! it possible when greeting a person would it automatically increment the counter?...


everything looks fine..thanks for your assistance


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.