Last active
August 6, 2023 18:23
-
-
Save KevinAlavik/b9e7c470d9c03fd4e6628e1c525a5651 to your computer and use it in GitHub Desktop.
Simple page switching function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let displayType = 'flex'; | |
function switchPage(page) { | |
const pages = document.querySelectorAll('.page-container'); | |
for (let i = 0; i < pages.length; i++) { | |
if (pages[i].getAttribute('page') === page) { | |
pages[i].style.display = displayType; | |
} else { | |
pages[i].style.display = 'none'; | |
} | |
} | |
} |
To use any other displaytype other the flex just change the variable!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: