How do you open a modal in Bootstrap?

<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">Open</button>
const modal = new bootstrap.Modal(document.getElementById('myModal'));
modal.show();

See Modal.


Learn more about the similar topics:
Tutorials
Bootstrap Modal
Bootstrap Collapse and Accordion
Bootstrap Carousel
Bootstrap Tooltips and Popovers
Bootstrap Offcanvas
Bootstrap Toasts
Bootstrap JavaScript: Data Attributes, API and Events
Exercises & Assignments
Open a modal with a button
Create an accordion with three items
Create a carousel with three slides
Add a tooltip to a button
Create an offcanvas sidebar which opens from the left
Interview Questions & Answers
How do you open a modal in Bootstrap?
How do you create a carousel in Bootstrap?
What are data-bs-* attributes in Bootstrap?
How do you initialize tooltips and popovers in Bootstrap 5?
What is the offcanvas component in Bootstrap?
What is Popper and why does Bootstrap need it?
How do you use the Bootstrap JavaScript API?