This is a rather simple task, so instead of giving complete solution let me help you to make it yourself.
First of all, let’s write an algorithm that will describe what we want to achieve:
- Hold two values (
prevYear
,nextYear
) in memory; - Output each of them into corresponding
div
on the page; - When user clicks “back”:
3.1. DecreaseprevYear
value (substract 1 from it);
3.2. Output newprevYear
value into correspondingdiv
; - When user clicks “next”:
4.1. IncreasenextYear
value (add 1 to it);
4.2. Output newnextYear
value into correspondingdiv
;
Then let’s think what tools we can use to implement that algorithm:
- To store and manipulate with values we can use variables;
- To output values there is jQuery’s html() method;
- To listen for user clicks there is jQuery’s
click()
method that you’re already using.
Now, try to implement final solution.
Feel free to ask if you’ll stuck somewhere.