Is there a way to properly hide and show a Bootstrap 5 input-group
? You can see an example here:
I'm facing an issue where once the input group is hidden, it doesn't show correctly when displayed again. How can I ensure that this functionality works as intended?
function dotoggle() {
elem = document.getElementById("hideme")
if (elem.style.display == "none") {
elem.style.display = "block";
} else {
elem.style.display = "none";
}
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="55373a3a21262127342515607b65783730213467">[email protected]</a>/dist/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="input-group mb-3" id="hideme">
<span class="input-group-text" id="basic-addon1">@</span>
<input type="text" class="form-control" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1">
</div>
<button onclick="dotoggle()">
BUTTON
</button>