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


#1

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

#2

Instead of

var clicks = 0++;

try

var clicks = 0;

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


#3

onclick should be all lowercase according to documentation


#4

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


#5

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


#6

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


#7

everything looks fine..thanks for your assistance


#8

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