How to increment a numeric string by +1 with Javascript/jQuery -


i have following variable:

pageid = 7 

i'd increment number on link:

$('#arrowright').attr('href', 'page.html?='+pageid); 

so outputs 7, i'd append link 8. if add +1:

$('#arrowright').attr('href', 'page.html?='+pageid+1);

i following output: 1.html?=71 instead of 8.

how can increment number pageid+1?

try this:

parseint(pageid, 10) + 1 

accordint code:

$('#arrowright').attr('href', 'page.html?='+ (parseint(pageid, 10) + 1)); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -