3
- I have a variable
x
that is written on the screen with initial value 0; - I want every click on a button (be
input
orbutton
same) in HTML file, the value of this variable is added 1; - When added, I want the variable, which is written on the screen, to show the current value of the same.
I tried it this way:
var pontos = 0;
$(document).ready(function() {
$('#pontos').text('Olá! O seu recorde é de ' + pontos + ' pontos.');
$('#addPonto').click(function() {
pontos++;
});
});
When doing this, I want the value written on the screen to be updated. How to proceed?
Thank you very much, Sergio. I was a while without internet access, so the delay.
– Gabriel Azevedo