+ 2
Buttons??
I was messing about with a friend and trying to create a simple clicker game. However it didn't work. When we clicked the button, the button would disappear. Here is the code: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <button onclick="myFunction()">Enter</button> <script> var a = 0; document.write(a); function myFunction(){ a = a + 1; document.write(a); } </script> </body> </html> Thanks to anyone who helps!
8 Respuestas
+ 4
Hello! Here new code the game clicker ↓↓↓
<button onclick="Func()"> click </button>
<p id="main"> 0 </p>
<script>
var count = 0;
function Func() {
document.getElementById('main').innerHTML = ++count;
}
</script>
+ 3
You can do this as follows ↓↓↓ :)
<button onclick="Func()"> click </button>
<p id="main"> 0s</p>
<script>
var count = 0;
function Func() {
document.getElementById('main').innerHTML = ++count + "s";
}
</script>
+ 3
<button onclick="Func()"> click </button>
<p id="main"> 0s</p>
<script>
var count = 0;
function Func() {
document.getElementById('main').innerHTML = ++count + "s";
count = ++count / 1;
}
</script>
try it ↑↑↑ :)
+ 2
Thanks!!
+ 1
Sorry about this, but if I wanted to increase the amount the number would go up in e.g 2s how would I do that?
+ 1
ok thanks again
+ 1
I wrote the question wrong. I mean whenever I click the button ot will display 2 then 4 then 6 etc
+ 1
ok sorry about the hassle. thanks