I want a counter that increases on button click. I tried the following code, but the value printed stays the same:
$(document).ready(function () {
$("#gonder").click(function() {
var baslik = document.title;
var sayi = 1;
var sayi1 = sayi++;
document.title = '(' +sayi+ ')' + baslik;
});
});
What how can I do my want?
You need to initialize your counter outside of the function. You were clearing it on every click.