Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  75] [ 6]  / answers: 1 / hits: 46994  / 12 Years ago, mon, july 2, 2012, 12:00:00

I have the following variable:



pageID = 7


I'd like to increment this number on a link:



$('#arrowRight').attr('href', 'page.html?='+pageID);


So this outputs 7, I'd like to append the link to say 8. But if I add +1:




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




I get the following output: 1.html?=71 instead of 8.



How can I increment this number to be pageID+1?


More From » jquery

 Answers
2

Try this:



parseInt(pageID, 10) + 1


Accordint to your code:



$('#arrowRight').attr('href', 'page.html?='+ (parseInt(pageID, 10) + 1));

[#84522] Sunday, July 1, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dusty

Total Points: 739
Total Questions: 97
Total Answers: 85

Location: Angola
Member since Wed, Apr 13, 2022
2 Years ago
;