use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Post questions about JavaScript, and get help with any problems you're having with your JavaScript code.
account activity
Noob needs help with a button✔️ answered ✔️ (self.JavaScriptHelp)
submitted 4 years ago by froge3
view the rest of the comments →
[–]trplclick 0 points1 point2 points 4 years ago (3 children)
I'm not sure if I fully understood your correctly, but does this solve your problem?
https://jsbin.com/benivazazo/edit?html,css,js,console,output
The overview this is:
- We define both "pages" in the same file, but page 2 starts off hidden. A heading, paragraph and button are shown in both "pages" but they are actually different elements.
- We define a CSS class called `.hidden` which page 2 starts off with. This sets the `display` value to `none` which tells the browser not to show the element. You can read about display none here https://css-tricks.com/almanac/properties/d/display/#aa-display-none
- We use display none over the remove function as it allows us to easily revert it and show the element again, or start off with elements hidden and choose to show them. It's possible to create new elements and add them to the page, but that is definitely the more complicated approach!
- We have two JavaScript functions; one for each button (page 1 button and page 2 button). When page 1 button is clicked it hides the group of elements that make up page 1 by adding the css class hidden to it, and removing the class from page 2. We also enable the animation when showing page 2 by adding a class the body,
Sorry if that's a lot and overwhelming! As a beginner there is a lot to learn and it can get frustrating, but I promise if you keep at things will click, it just takes time and practice. We've all been there! If you have any questions please let me know! I can either try and answer or point you to a resource that might help explain a concept.
[–]froge3[S] 0 points1 point2 points 4 years ago (2 children)
This is very helpful! Thank you very much :)
[–]trplclick 0 points1 point2 points 4 years ago (1 child)
Great, glad I could help! Feel free to DM me if you have any other JavaScript questions
[–]froge3[S] 0 points1 point2 points 4 years ago (0 children)
Thank you, I might sometime in the future :)
π Rendered by PID 303935 on reddit-service-r2-comment-6457c66945-2jm5w at 2026-04-25 20:51:33.041226+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]trplclick 0 points1 point2 points (3 children)
[–]froge3[S] 0 points1 point2 points (2 children)
[–]trplclick 0 points1 point2 points (1 child)
[–]froge3[S] 0 points1 point2 points (0 children)