You need to use parseInt
to convert kacbegen
, which is a String
instance, to a Number
:
var begen = $(this).attr('id');
var kacbegen = $("#math" + begen).text();
var toplam = (parseInt(kacbegen) + 1);
alert(toplam);
The +
operator, when used with a String
on either side, will serve as a concatenation, calling Number.prototype.toString
on 1
.