Rachel S Rachel S - 1 year ago 133
Javascript Question

Hide a Bootstrap collapse trigger button after

I have a button to trigger a collapsed dive and open it. I would like to make the button disappear once it's been clicked.


<button id="show-more-home" data-toggle="collapse" data-target="#demo" class="btn btn-default"><i class="ion-chevron-down"></i> </button>

I tried this js but no go:


Answer Source

You can just use the jQuery .hide() function:

  $("body").on('click','#show-more-home', function(){ $(this).hide(); });

or if you have a .hidden class like:

.hidden {display:none !important;} 

you can also hide it like:

  $("body").on('click','#show-more-home',function(){ $(this).addClass('hidden'); });
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download