To only display the appropriate div when clicking a button on the left navbar and hide all others, you can use this code:
For example:
- If "Profile" is clicked in the left navbar, the My Profile Form div will be displayed (and all others will remain hidden).
- If "My Properties" is clicked in the left navbar, the My Properties div will be displayed (and all others will remain hidden).
- And so on for the rest of the buttons.
To accomplish this, you can utilize the following JavaScript:
const ProfileForm = document.getElementById('profile_container');
const ProfileButton = document.getElementById('profile_id');
const PropertiesForm = document.getElementById('my_properties_container');
const BidsForm = document.getElementById('my_bids');
const UtilitiesForm = document.getElementById('my_utilities');
const FavouritesForm = document.getElementById('my_favourites');
const MessagesForm = document.getElementById('my_messages');
const SettingsForm = document.getElementById('my_settings');
document.body.addEventListener('click', e => {
if (e.target == ProfileButton) {
ProfileForm.style.display = 'block'
} else { /*ProfileForm.style.display='none'*/ }
})
In order to style your elements appropriately, here's an example snippet of CSS:
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
/* Your CSS styles here */
Make sure to include these scripts and stylesheet links in the head section of your HTML file:
<script src="https://kit.fontawesome.com/99c0db90d1.js" crossorigin="anonymous"></script>
<link rel="shortcut icon" type="image/jpg" href="images/33.png" />
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<link href="/css/all.css" rel="stylesheet">