1
I’m putting together a quiz where each click takes the user to a part of the quiz. Everything is loaded on the same page so it doesn’t jump between pages. Each slide is contained in its own div
and inside them the buttons that lead to other slides.
How does it react: when in the main slide i click on the link that leads to the slide1 o main slide is hidden and slide1 goes into place (using Hide and show css) and so on, when in slide1 click to go pro slide1-1 the slide1 is hidden and the slide1-1 appears.
I would like a Javascript function to do this. I have searched the forum but could not implement it to work directly. I have little knowledge in Javascript but I understand well logic.
This is a test html I’m using
<html>
<body>
<div class="main">MAIN
<a href="#">slide1</a>
<a href="#">slide2</a>
</div>
<!-- second layer -->
<div class="slide1>SLIDE1
<a href="#">slide1-1</a>
<a href="#">slide1-2</a>
</div>
<div class="slide2">SLIDE2
<a href="#">slide2-1</a>
<a href="#">slide2-2</a>
</div>
<!-- third layer -->
<div class="slide1-1">SLIDE1-1</div>
<div class="slide1-2">SLIDE1-2</div>
<div class="slide2-1">SLIDE2-1</div>
<div class="slide2-2">SLIDE2-2</div>
</body>
</html>
Diego is exactly that ! Thank you for the time devoted to the answer
– gabriel
I liked your script. It’s more complex, but it’s easy to change. I tried to answer more simply.
– Rafael Marcos
@Rafaelmarcos In this case, I like to keep JS and HTML well separated, I like this type of organization better. Compared to your code the logic was the same, adds the onclick event, hides all by one class and searches for a selector. :)
– Diego Marques