I want html/Js/css code for a webpage of atleast 5-10 sentences wherein each sentence should appear on click. Moreover, as all the content of that page appears, it should lead to another similiar page on the next click. Can you help?
Asked
Active
Viewed 227 times
0
-
1What have you tried so far? – Aalexander Dec 18 '20 at 12:04
-
Welcome to StackOverflow [tour](https://stackoverflow.com/tour). Please read and follow the posting guidelines [how to ask](https://stackoverflow.com/help/how-to-ask), as suggested when you created this account. – Youba Dec 18 '20 at 12:08
-
Not a homework website. – Maddy Dec 18 '20 at 13:31
1 Answers
0
Try this, click inside the top area this is the body in this snippet here
let textelements = document.querySelectorAll(".text");
let counter = 0;
function clicker(){
if(counter < textelements.length){
textelements[counter].style.visibility = "visible";
counter ++
} else{
window.location.replace("<somepage>");
}
}
.text{
visibility: hidden
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<div id="text1" class="text">Hello how</div>
<div id="text2" class="text">do you do</div>
<div id="text3" class="text">today</div>
<button class="btn" onclick="clicker()">Click Me</button>
</body>

Aalexander
- 4,987
- 3
- 11
- 34
-
Thanks for your help. Kindly add a button at the bottom of the page for click. Moreover, the next page should also be a similar page and not a website link. Hope you will update your answer. – T. A. Wani Dec 18 '20 at 12:35
-
what do you mean by similiar page? this was just an example to show that it works – Aalexander Dec 18 '20 at 12:40
-
-
if you have second html file then you can go there with the following command `window.location.href = '../'; //one level up` there you can give the relative path to your second file. here is an good answer https://stackoverflow.com/questions/1655065/redirecting-to-a-relative-url-in-javascript – Aalexander Dec 18 '20 at 13:24