How can one hide / show an input-group in Bootstrap

I’m trying to hide / show a Bootstrap 5 input-group as shown here:

https://jsfiddle.net/o08r3p9u

However, once hidden, the input group no longer shows correctly when shown again. How can this functionality be properly implemented?

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/bootstrap@5.0.0-beta2/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>

451 thoughts on “How can one hide / show an input-group in Bootstrap”

  1. I believe what you said was very reasonable. But,
    what about this? suppose you wrote a catchier post title?
    I ain’t saying your content isn’t good, however suppose you added a post title that makes people want more?
    I mean How can one hide / show an input-group in Bootstrap – JavaScript Help is a little boring.
    You could look at Yahoo’s home page and see how they create article headlines to
    get viewers to open the links. You might try adding
    a video or a related pic or two to get people interested about what you’ve written. In my
    opinion, it might make your posts a little livelier. http://herreramedical.org/azithromycin

    Reply
  2. Hey I know this is off topic but I was wondering if you knew of any widgets I
    could add to my blog that automatically tweet my newest twitter updates.

    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something
    like this. Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward to your new updates. https://buszcentrum.com/deltasone.htm

    Reply
  3. Pingback: ivermect 6
  4. It’s a shame you don’t have a donate button! I’d without a doubt donate to this fantastic blog!
    I guess for now i’ll settle for bookmarking and
    adding your RSS feed to my Google account. I look forward to fresh updates and
    will talk about this blog with my Facebook group. Talk soon!

    Reply
  5. Attractive portion of content. I simply stumbled upon your blog and in accession capital
    to assert that I acquire in fact enjoyed account your blog posts.

    Any way I’ll be subscribing to your augment or
    even I fulfillment you access persistently quickly.

    Reply
  6. Just want to say your article is as amazing. The clarity to your
    publish is simply great and that i can assume you are a professional on this
    subject. Well together with your permission allow me
    to grasp your feed to stay updated with impending post.

    Thanks one million and please continue the enjoyable work.

    Reply
  7. Pingback: ivermectay 6 mg
  8. Pingback: buy plaquenil
  9. Yesterday, while I was at work, my sister stole my iphone and tested
    to see if it can survive a forty foot drop,
    just so she can be a youtube sensation. My apple
    ipad is now broken and she has 83 views. I know this is totally off topic but
    I had to share it with someone!

    Reply
  10. Pingback: sex games ios
  11. [url=http://modafinil24.com/]provigil 100mg tablets[/url] [url=http://buyavodart.shop/]avodart .5 mg[/url] [url=http://buyneurontin.shop/]buy neurontin[/url] [url=http://sildalis.boutique/]sildalis[/url] [url=http://cozaar.shop/]cozaar 50 mg price[/url] [url=http://ampicillin.shop/]purchase ampicillin online[/url] [url=http://tadacip.cfd/]tadacip for sale[/url]

    Reply

Leave a Comment