Currently, I am working on a website project that utilizes bootstrap. However, I am facing some uncertainty regarding how to effectively hide and display text:
<nav class="navbar navbar-light" style="background-color: #e3f2fd;">
<a class="navbar-brand" href="#">Navigate:</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="index.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="price.html">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
</div>
</nav>
I am specifically focused on the
<a class="navbar-brand" href="#">Navigate:</a>
element, where I want it to only be visible when users click the button to toggle the menu dropdown. Once they close the menu, this text should disappear. In essence, Navigate:
should only show up when the menu is dropped down.
Despite my attempts, I have not been successful in achieving this functionality:
<script>
function display(){
if(document.getElementById("navbar-brand").style.display == "none"){
document.getElementById("navbar-brand").style.display = "inline"
}
if(document.getElementById("navbar-brand").style.display == "inline"){
document.getElementById("navbar-brand").style.display = "none"
}
}
</script>
<a class="navbar-brand" href="#">Navigate:</a>
<button class="navbar-toggler" on-click="display()" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle
navigation">