A
A
Alexey Korolev2022-01-25 01:53:40
Bootstrap
Alexey Korolev, 2022-01-25 01:53:40

How to collapse a column in bootstrap?

There is the following structure. How can I hide the menu when I press the button?

<div class="row">
<div class="col-lg">контент <button>Скрыть меню</button></div>
<div class="col-lg-4">меню </div>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2022-01-25
@delphinpro

<div class="row">
  <div class="col-lg">контент <button id=menuToggle>Скрыть меню</button></div>
  <div class="col-lg-4" id=menu>меню </div>
</div>
<script>
  document.getElementById('menuToggle').addEventListener('click', ()
    => document.getElementById('menu').classList.toggle('d-none'));
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question