Navigating a dashboard with js only

I want to know how to navigate through a dashboard contents like(profile, settings, analytics...) Using only js... because I am a beginner and I still don't know react... Could I change the content of the same container each time or this will be a bad practice
2 Replies
Wolle
Wolle16mo ago
Changing the content of a container is how frameworks (Vue/React/Svelte/..) usually work, so not bad practice. An alternative would be hiding/showing the content (by toggling a class).
ἔρως
ἔρως16mo ago
if i were you, i would keep 2 elements inside the container: an element with placeholder content/loading spinner and the other one is what you change then, you swap between both, showing and hidding the content before you change it, if you need to fetch information you can use a document fragment to add all the changes, and then append it to the element you want to, and it adds everything at once this assumes you arent using any frameworks if you just need to show and hide some content, you can try to check the <details> class
Want results from more Discord servers?
Add your server