Bootstrap Modals offer a lightweight, multi-purpose JavaScript popup that’s customizable and responsive. They can be used to display alert popups, videos, and images in a website. Bootstrap Modals are divided into three primary sections: header, body, and footer.
Syntax:
class | tabindex | role | aria-labelledby
Approach: It shows the pop-up menu with the header, body, and footer with the close and submits button.
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> </div> </div> |
Explanation: Below is a static modal example (meaning its position and display have been overridden) including the modal header, modal body (required for padding), and modal footer (optional). We ask that you include modal headers with dismiss actions whenever possible, or provide another explicit dismiss action.
Example:
<!DOCTYPE html> <html> <head> <title></title> <link rel="stylesheet" href= integrity= "sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> integrity= "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src= integrity= "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src= integrity= "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> </head> <body> <!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal"> Launch demo modal </button> <!-- Modal --> <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel"> Modal title </h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> ... </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary"> Save changes</button> </div> </div> </div> </div> </body> </html> |
$('#myModal').on('shown.bs.modal', function () { $('#myInput').trigger('focus') }) |
Output:

Supported Browsers: It supports in Flex layout.
- Chrome: Yes
- Firefox: Yes (63.0)
- Edge: No
- Internet Explorer: No
Recommended Posts:
- How to handle the modal closing event in Twitter Bootstrap?
- How to use complex HTML with twitter Bootstrap tooltip using jQuery ?
- How to use Bootstrap modal for YouTube videos and play automatically ?
- How to change the width and height of Twitter Bootstrap's tooltips?
- How to Check Twitter Bootstrap is Loaded or not ?
- How to Automatically Close Alerts using Twitter Bootstrap ?
- How to hide element on small devices in Twitter Bootstrap ?
- Data-toggle attributes in Twitter Bootstrap
- How to configure modal width in Bootstrap?
- Modal JavaScript plugin (bootstrap) with example
- How to hide Bootstrap modal with JavaScript?
- Bootstrap 4 | Modal
- How to get the same behavior with confirm and bootstrap modal?
- What does .modal('dispose') do in Bootstrap 4 ?
- How to open or close react-bootstrap modal pro-grammatically?
- How to change the position of modal close button in bootstrap?
- How to fit the image into modal popup using Bootstrap?
- Bootstrap 5 Modal
- How to use a div as content for Twitter's Popover?
- How to detect browser or tab closing in JavaScript ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Akanksha_Rai

