vngx
August 29, 2015, 3:41pm
1
Hi there
this is my jsfiddle
What I want that there should be some value change when user clicks on back and next label
Like in current case there is backyear value is 2014 when user clicks on “back” it should change to 2013 and when user clicks on “next” it should change to “2015” in nextyear
How can I acheive this?
I need preconfigured value in js file and there should be a limit on it
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. Decrease prevYear
value (substract 1 from it);
3.2. Output new prevYear
value into corresponding div
;
When user clicks “next”:
4.1. Increase nextYear
value (add 1 to it);
4.2. Output new nextYear
value into corresponding div
;
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.
system
Closed
December 3, 2015, 12:11pm
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.