Rachel S Rachel S - 3 months ago 5x
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:



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'); });