This is simple. A button makes all 4 divs hidden, and the makes the div that relates to the button show. Basically, it switches out content. Here is what I have:
I KNOW this can be reduced though. Here is something else that I tried but it didn’t work.
I think the answer is going to lay in giving each of the elements you are attaching click handlers to a common class name. Then maybe on each of those anchor links, put a rel attribute like <a id="bottoms" rel="1">…</a> Then use that rel value inside the selector for the second statement.
Thanks for all the help posted, especially you Chris. I’m sure you’re really busy. By the way, thank you for all the help this site has given me.
Sorry for not explaining it properly in my first post. I just realized i misworded it. I meant to say that there are 4 buttons, each when clicked, shows the div of content it corresponds to, and the hiding the other 3. It was supposed to be so a viewer can click a category of clothes and see an image of it.
Anyways, to the solution. Here is what I narrowed it down to.
The $(‘#slider-content div:eq(0)’).siblings().hide(); switches divs 2 through 4 so hidden by default.
The next 2 lines make it so whenever one of the buttons is clicked, all the divs are hidden.
And the rest will show the corresponding div when a button is clicked. The user can now click any of the buttons and go back and forth as much as they want, no hassle. Also, it’s a lot less code than there was initially and I don’t have to create any classes.
You must be logged in to reply to this topic.