Reputation: 470
So I've got a span that goes like this:
<span>1</span>
Now I want to do something like this (plus it)
$(this).next("span").text($(this).next("span").text + 1);
But it won't work. You're seeing where I'm going though, right? I want to make the number in the string or variable go one higher.
How can I do that?
Upvotes: 1
Views: 2019
Reputation: 9272
Try the JavaScript parseInt()
function. Be sure you properly handle error cases, as in someone putting an invalid integer value into the span.
Upvotes: 4