screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bootstrap 5 Modal Example</title> <!-- Include Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <!-- Button to trigger the modal --> <h3>Bootstrap Modal Pass data Dynamically</h3> <button type="button" class="btn btn-primary" data-bs-toggle="modal" id='open-modal' data-bs-target="#myModal">Open Modal</button> <!-- Modal --> <div class="modal fade" id="myModal"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="myModalLabel"></h4> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <p></p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> </div> </div> </div> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js"></script> <script> document.addEventListener('DOMContentLoaded', function () { var openModalButton = document.getElementById('open-modal'); openModalButton.addEventListener('click', function () { var title = 'Bootstrap Modal Pass Data Dynamically using Javascript Method'; var paragraph = 'This Text is Dynamically ' + new Date(); var modalTitle = document.querySelector('.modal-title'); var modalBody = document.querySelector('.modal-body p'); modalTitle.textContent = title; modalBody.textContent = paragraph; }); }); </script> </body> </html>