bootstrap 5.3.3 can `data-bs-toggle` toggle `button` and `collapse` together?

Is it possible to toggle button and collapse together?
Button 1 toggles the text
Button 2 toggles the button (active/inactive)
Button 3 shall toggle both together

    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<div class="container">
  <ul class="nav nav-tabs">

  <li class="nav-item">
    <a class="nav-link active" data-bs-toggle="collapse" href="#test" role="button" aria-expanded="false" aria-controls="test">collapse</a>
  </li>
    <li class="nav-item">
    <a class="nav-link active" data-bs-toggle="button" href="#test2" role="button" aria-expanded="false" aria-controls="test2">button</a>
  </li>
      <li class="nav-item">
    <a class="nav-link active" data-bs-toggle="button collapse" href="#test3" role="button" aria-expanded="false" aria-controls="test3">both - not working</a>
  </li>
</ul>
    <div class="collapse multi-collapse" id="test">
    collapse
    </div>
        <div class="collapse multi-collapse" id="test3">
    both
    </div>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"

At the same time tou can’t with the default events from bootstrap.
But you can do it yourself with JS.
So, if you want this:
#button1 toggle the collapse #test.
#button2 toggle himself.
#button2 toggle #button2 and the collapse test3.
You can do something like this with the bootstrap js methods.

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<div class="container">
  <ul class="nav nav-tabs">
    <li class="nav-item">
      <a class="nav-link active" href="#test" role="button" aria-expanded="false" aria-controls="test" id="button1">collapse</a>
    </li>
      <li class="nav-item">
      <a class="nav-link active" href="#test2" role="button" aria-expanded="false" aria-controls="test2" id="button2">button</a>
    </li>
        <li class="nav-item">
      <a class="nav-link active" href="#test3" role="button" aria-expanded="false" aria-controls="test3" id="button3">toggle button and collapse test 3</a>
    </li>
  </ul>
  <div class="collapse multi-collapse" id="test">
    collapse
  </div>
  <div class="collapse multi-collapse" id="test3">
    both
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function () {
      let button1 = document.querySelector('#button1');
      let button2 = document.querySelector('#button2');
      let button3 = document.querySelector('#button3');

      const bsCollapse = new bootstrap.Collapse('#test')
      const bsCollapse3 = new bootstrap.Collapse('#test3')
      const bsButton = new bootstrap.Button('#button2')

      button1.addEventListener('click', function () {
        bsCollapse.toggle();
      });
      button2.addEventListener('click', function () {
        bsButton.toggle();
      });
      button3.addEventListener('click', function () {
        bsCollapse3.toggle();
        bsButton.toggle();
      });
    });
  </script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>

3

This is good example from Bootstrap website

https://getbootstrap.com/docs/5.0/components/collapse/#multiple-targets

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <title>Document</title>
</head>
<body>
    <p>
        <a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Toggle first element</a>
        <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#multiCollapseExample2" aria-expanded="false" aria-controls="multiCollapseExample2">Toggle second element</button>
        <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>
      </p>
      <div class="row">
        <div class="col">
          <div class="collapse multi-collapse" id="multiCollapseExample1">
            <div class="card card-body">
              Some placeholder content for the first collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
            </div>
          </div>
        </div>
        <div class="col">
          <div class="collapse multi-collapse" id="multiCollapseExample2">
            <div class="card card-body">
              Some placeholder content for the second collapse component of this multi-collapse example. This panel is hidden by default but revealed when the user activates the relevant trigger.
            </div>
          </div>
        </div>
      </div>
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

</body>
</html>

in this example you can control cards with data-bs-target

so when data-bs-toggle triger cards with class in data-bs-target will change

 <button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".multi-collapse" aria-expanded="false" aria-controls="multiCollapseExample1 multiCollapseExample2">Toggle both elements</button>

if see this code notice when this button clicked 2 cards will be change

what if one of them will be open and other one its close well first one will be close and secound card will be open

in your case will be like this

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <title>Document</title>
</head>

<body>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <div class="container">
        <ul class="nav nav-tabs">

            <li class="nav-item">
                <a class="nav-link active" data-bs-toggle="collapse" href="#test" role="button" aria-expanded="false"
                    aria-controls="test">collapse</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" data-bs-toggle="collapse" href="#test2" role="button" aria-expanded="false"
                    aria-controls="test2">button</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" data-bs-toggle="collapse" data-bs-target=".collapse" href="#test3" role="button"
                    aria-expanded="false" >both - not working</a>
            </li>
        </ul>
        <div class="collapse multi-collapse" id="test">
            collapse
        </div>
        <div class="collapse multi-collapse" id="test2">
            both
        </div>
        <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
            integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
            crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
</body>

</html>

so i add data-bs-target=”.collapse” to anchor with text both – not working

and you set data-bs-toggle=”button” in anchore with href=”#test2″ while there is no tag with class button so i change this to collapse

also base on w3school says

Note: For <a> elements, you can use the href attribute instead of the
data-bs-target attribute

so instead of data-bs-target you can just use href like this

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <title>Document</title>
</head>

<body>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
    <div class="container">
        <ul class="nav nav-tabs">

            <li class="nav-item">
                <a class="nav-link active" data-bs-toggle="collapse" href="#test" role="button" aria-expanded="false"
                    aria-controls="test">collapse</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" data-bs-toggle="collapse" href="#test2" role="button" aria-expanded="false"
                    aria-controls="test2">button</a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" data-bs-toggle="collapse"  href=".test3" role="button"
                    aria-expanded="false" >both - not working</a>
            </li>
        </ul>
        <div class="collapse multi-collapse test3" id="test">
            collapse
        </div>
        <div class="collapse multi-collapse test3" id="test2">
            both
        </div>
        <script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
            integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r"
            crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
</body>

</html>

i did change the href for anchor with text (both – not working) to href=".test3" and added test3 to both div classes

<div class="collapse multi-collapse test3" id="test">
        collapse
    </div>
    <div class="collapse multi-collapse test3" id="test2">
        both
    </div>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật