<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="424147474c4a4a4c5f7e79777a">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="41524343485f4d515451544152460353545087427b747b6d4055505b55565d54">[email protected]</a>/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous" defer></script>
<button data-bs-toggle="collapse" data-bs-target="#navmenu">TOGGLE</button>
<div class="collapse" id="navmenu">
<div>ONE</div>
<div>TWO</div>
<div>THREE</div>
</div>
Can someone explain why the data-bs-toggle
attribute only works for the collapse
class and not other class names like asd
? Why does it successfully toggle with the keyword dropdown
in combination with the class name dropdown-menu
? How does this logic work differently depending on the class or id specified?
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="491b16160d0a0d0b18190146411d02170c000f54130805031c00">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5537302d390a10196667457f65685fffffffddf83859e52687f7273">[email protected]</a>/dist/umd/popper.min.js" integrity="sha384-7+zCNj/IqJ95wo16oMtfsKbZ9ccEh31eOz1HGyDuCQ6wgnyJNSYdrPa03rtR1zdB" crossorigin="anonymous" defer></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ba9895928592898f9cadaaa597aebbb47">[email protected]</a>/dist/js/bootstrap.min.js" integrity="sha384-QJHtvGhmr9XOIpI6YVutG+2QOK9T+ZnN4kzFN1RtK3zEFEIsxhlmWl5/YESvpZ13" crossorigin="anonymous" defer></script>
<div>
<button data-bs-toggle="dropdown">
Dropdown link
</button>
<div class="dropdown-menu">
<div>ONE</div>
<div>TWO</div>
<div>THREE</div>
</div>
</div>
Could anyone clarify the specific functionality behind the data-bs-target
and data-bs-toggle
attributes, particularly when used with classes like collapse
and dropdown
? Why is the element targeted different for a dropdown menu with the class dropdown-menu
instead of just dropdown
? The Bootstrap documentation doesn't provide clear explanations.
Seeking an understanding of these concepts. Your insights would be greatly appreciated!