Reputation: 61775
$('#fCount' + folderID).html(parseInt($('#fCount' + folderID).html()) + "E");
That works, but whatever I try such as:
$('#fCount' + folderID).html(parseInt($('#fCount' + folderID).html())++);
Doesn't work! The html is just a number, like 0 or 8. I just want to increment it by one.
Upvotes: 2
Views: 975
Reputation: 26436
You want:
$('#fCount' + folderID).html(parseInt($('#fCount' + folderID).html())+1);
The ++
operator won't work in this case. It can only be used for variables. You need to do +1
.
Here's a working demo.
Upvotes: 4
Reputation: 179256
the ++
operator only works on variables that you maintain a reference to. In this case you don't have a reference to a value, you have an actual value being returned. You'll either need to store the value in a variable, and then increment the number, or add one manually:
something = parseInt(someString)+1
Upvotes: 1
Reputation: 238065
You need to simply add one (+1
) rather than incrementing, which only works on a variable.
You could also use this rather nicer jQuery syntax:
$('#fCount' + folderID).html(function(i, oldHtml) {
return parseInt(oldHtml, 10) + 1;
});
Upvotes: 1