I have to create a page in HTML5 using jQuery in which all questions will be there in the form of table. By clicking on a particular question – it’s answer should appear sliding; on closing that answer the slider should go back and the questions should appear.
How is this possible? Should I use <div> for values or to fetch it from XML? Please guide with your suggestions and tutorials.
Here is a primordial example on how to do it:
demo jsBin
you need this HTML structure:
And this basic jQuery:
what we do here is: get the index N of the clicked
lielement +1.+1 cause we are already looking at the first box (with the questions), but all the other
.boxelements will be +1 index higher.After we have that number we just animate the slider at “speed” (time) 1000 doing some simple math: we multiply the gotten index N by the ‘viewport’ width.
To go back we just animate the
.sliderback to theleft:0px(or just ‘0’) position.If you don’t understand some of the methods I used, you can find them here: http://api.jquery.com/
(PLEASE next time show some effort in asking your questions so we can look at some code of yours. Thanks! Happy coding)