![]() |
VOOZH | about |
Bootstrap 5 Modal Via data attributes can activate a modal, by setting data-bs-toggle="modal" on an element, like a button. We can also toggle a specific modal by using a data-bs-target="#foo" or href="#foo".
Bootstrap 5 Modal Via data attributes:
Syntax:
<button type="button" data-bs-toggle="..." data-bs-target="..."> ... </button>
Example 1: In this example, we will learn how to activate a modal using <button>
Output:
Example 2: In this example, we will learn how to activate a modal using <a> tag
Output:
References: https://getbootstrap.com/docs/5.0/components/modal/#via-data-attributes