Reputation: 6355
Hi I'm currently experimenting with JQuery, my aim is to have a few divs which can be toggled between using arrows. I have a JSFiddle which shows what I have so far, but I think there is a simpler way to achieve what I want to achieve.
I want to be able to keep toggling through the divs when I press the arrows rather than using show and hide.
http://jsfiddle.net/gutigrewal90/ZW3kY/
Any help would be much appreciated!
Upvotes: 0
Views: 395
Reputation: 10966
Here's an updated jsfiddle where you can add as many div
s as you want to your DOM now. The solution is to look for next
or first sibling
of current visible element.
currentElem.hide();
if (currentElem.next().length > 0) {
currentElem = currentElem.next().show();
} else {
currentElem = currentElem.siblings().first().show();
}
Upvotes: 1