var c = 0; function Click() { с++; } //while (true) { // закомментировал, потому, что это бесконечный цикл... //document.getElementById('click').innerHTML = c; //} 
 <input type="button" value="Клик" onclick="Click()" /> <div id="click"></div> 

What's wrong?

  • And you try to execute the code. - 0xdb
  • @ 0xdb what an evil uncle) - Aleksey Shimansky
  • @ Alexey Shimansky where? I? I'm not angry, I'm fair - 0xdb

1 answer 1

least

 while (true) { 

runs an endless loop that hangs the page ...

and c - it seems that in some places it was Russian . In this connection, it is worth understanding that variables should have meaningful names, and not like after obfuscation

 var count = 0; function Click() { document.getElementById('click').innerHTML = count++; } Click(); 
 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Кликер</title> <link href="css/default.css" rel="stylesheet" /> <script src="js/main.js"></script> </head> <body> <input type="button" value="Клик" onclick="Click()" /> <div id="click"></div> </body> </html> 

  • However, keep in mind that the values ​​on the page and in the count in this situation will differ by one. - D-side
  • @ D-side yep. I wanted to write through ++count , but I thought that it would not be critical for the author - Alexey Shimansky