- I have a variable
x
that is written on the screen with initial value 0; - I want each click of a button (be
input
orbutton
same) in the HTML file, the value of that variable to be added 1; - When added, I want the variable, which is written on the screen, to show the current value of the variable.
I tried the following:
var pontos = 0;
$(document).ready(function() {
$('#pontos').text('Olá! O seu recorde é de ' + pontos + ' pontos.');
$('#addPonto').click(function() {
pontos++;
});
});
When you do this, I want the value written on the screen to be updated. How to proceed?