JavaScript Hiding button after collapse is toggled using Javascript hiding button after collapse is toggle in bootstrap

I'm trying to hide the "collapsible" button after it is being pressed.

activities.html:

<button class="collapsible"> <i class="fa fa-angle-down"></i></a></button>

Controller.js:

    var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
  coll[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var gallery1 = this.nextElementSibling;
    if (gallery1.style.maxHeight){
      gallery1.style.maxHeight = null;
    } else {
      gallery1.style.maxHeight = gallery1.scrollHeight + "px";
    } 
});
}

I would highly appreciate if someone could help me out of this!

Answer:1

To hide your button and remove the space occupied by the button on the page, use .style.display = 'none' on the button element in the event handler:

var coll = document.getElementsByClassName("collapsible");

for (var i = 0; i < coll.length; i++) {
  coll[i].addEventListener("click", function() {
    this.classList.toggle("active");    
    
    var gallery1 = this.nextElementSibling;
    
    if (gallery1.style.maxHeight) {
      gallery1.style.maxHeight = null;
    } else {
      gallery1.style.maxHeight = gallery1.scrollHeight + "px";
    }
    
    this.style.display = 'none';
  });
}
<link rel="stylesheet" type="text/css" target='_blank' href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<button class="collapsible"><a><i class="fa fa-angle-down"></i></a></button>
Answer:2

Jest has this feature to log the line that outputs to console methods. In some cases, this can become annoying: console.log _modules/log.js:37 ℹ login.0 screenshot start console.time _modules/...

Jest has this feature to log the line that outputs to console methods. In some cases, this can become annoying: console.log _modules/log.js:37 ℹ login.0 screenshot start console.time _modules/...

How could I change selected option for dropdown list using javascript or jQuery? <select id ="someId" name="someName"> <option>One</option> <option>Two</...

How could I change selected option for dropdown list using javascript or jQuery? <select id ="someId" name="someName"> <option>One</option> <option>Two</...

  1. selected option using jquery
  2. selected option using javascript
  3. selected option using angularjs
  4. set selected option using jquery
  5. get selected option using jquery
  6. change selected option using jquery
  7. get selected option using javascript
  8. set selected option using javascript
  9. change selected option using javascript
  10. show selected option using jquery
  11. get selected option using js
  12. remove selected option using jquery
  13. find selected option using jquery
  14. selected option value using php
  15. selected option value using jquery
  16. make option selected using jquery
  17. jquery set selected option using value
  18. jquery set selected option using index
  19. jquery get selected option using id
  20. get selected option value using jquery

I have these two strings: "1-2" and "1--2". I would like to have a regex that would match only the first occurrence of the hyphen in both strings, such that the split would then be: [1,2] and [1,-2]. ...

I have these two strings: "1-2" and "1--2". I would like to have a regex that would match only the first occurrence of the hyphen in both strings, such that the split would then be: [1,2] and [1,-2]. ...

  1. regex matching only numbers
  2. regex matching only letters
  3. regex matches only once
  4. regex matches only
  5. regex only matching first
  6. regex only matching last
  7. regex only matching first character
  8. regex unique matches only
  9. grep regex only matching
  10. regex return only matching string
  11. perl regex only matching

I'm using Node.js and I would like to check if a file exists and return the result to a property of a object. I'm trying like this: var file_exists = function(file) { return fs.stat(file, function(...

I'm using Node.js and I would like to check if a file exists and return the result to a property of a object. I'm trying like this: var file_exists = function(file) { return fs.stat(file, function(...

  1. check existence file python
  2. check existence file bash
  3. check existence file matlab
  4. check existence file powershell
  5. check existence file c++
  6. check existence file
  7. check existence file php
  8. check existence file linux
  9. check file existence java
  10. check file existence in shell script
  11. check file existence in unix
  12. check file existence ansible
  13. check file existence in perl
  14. check file existence shell
  15. check file existence vba
  16. check file existence r
  17. check file existence javascript
  18. check file existence nodejs
  19. check file existence in makefile
  20. check file existence batch