I want to hide a specific element when the burger button is clicked. (See CaptureElementNoDisplay.PNG for the element to hide)
When I click the burger button again to close the menu, I want the hidden item to be displayed once more.
I've successfully hidden the introduction element with the logo when displaying the menu. (Refer to CaptureElementNoDisplay.PNG)
However, I'm struggling to display the div containing the intro and logo in the center again. (See CaptureElementNoMoreDisplay.PNG)
Visit the website:
Here is the source code:
Source Code HTML :
<nav class="navbar navbar-dark justify-content-end" style="background-color: #0145FF;">
<button id="home" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-expanded="false" aria-label="Toggle navigation"> <span class=" navbar-toggler-icon "></span>
</button></nav>
<section id="intro1" style="height: 652px;background-color: #0145FF; ">
<div class="center logo-intro-1">
<img src="./assets/images/logo_adding.png " alt=" " width="450 ">
</div>
<ul class="nav flex-column text-right pr-5">
<li class="nav-item">
<a class="nav-link2 text-white" href="">Black</a></li>
<li class="nav-item"><a class="nav-link2 text-white" href="#">Red</a></li>
<li class="nav-item"><a class="nav-link2 text-white" href="#">Violet</a></li>
<li class="nav-item"><a class="nav-link2 text-white" href="#">Blue</a></li>
<li class="nav-item"><a class="nav-link2 text-white" href="#">Green</a></li></ul>
</section>
Source Code JavaScript :
$('.navbar-toggler').click(function() {
var booleanNoDisplay = true;
var intro1 = document.getElementById("intro1");
intro1.classList.add("NoDisplay");
if (booleanNoDisplay) {
console.log('ok TRUE');
$('#intro1').show(); // This line is not useful because the element is already displayed by default
booleanNoDisplay = false; //I don't know when to set the value to false...
}
if (!booleanNoDisplay) {
console.log('ok false');
$('#intro1').hide();
intro1.classList.add("display-block");
booleanNoDisplay = true;
}
});
Can you help identify where the issue might be coming from?
Thank you for your assistance in advance.https://i.sstatic.net/G70xU.png