Most common reason for such problems are

1.If you have defined the jquery library more than once.

Copy<script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

    <div class="modal fade" id="myModal" aria-hidden="true">
    ...
    ...
    </div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

The bootstrap library gets applied to the first jquery library but when you reload the jquery library, the original bootstrap load is lost(Modal function is in bootstrap).

2.Please wrap your JavaScript code inside

Copy$(document).ready(function(){});

3.Please check if the id of the modal is same

as the one you have defined for the component(Also check for duplication's of same id ).

Answer from Prakash Thete on Stack Overflow
🌐
GitHub
github.com › twbs › bootstrap › issues › 3902
modal('show') after a modal('hide') doesn't work · Issue #3902 · twbs/bootstrap
June 21, 2012 - immediately after hiding a modal, if a show call is issued it doesn't work e.g. $('#show_modal').click(function(){ $('#test-modal').modal('show') $('#test-modal').modal('hide') $('#test-modal').modal('show') }) ​ Looks like end effect sh...
Author   anuraguniyal
🌐
CodeIgniter
forum.codeigniter.com › thread-72601.html
Jquery UI modal show not working
CodeIgniter Forums Using CodeIgniter General Help Jquery UI modal show not working · Share on Google · Share on Facebook · Share on Twitter · View a Printable Version · Subscribe to this thread · Add Poll to this thread · Send thread to a friend · Linear Mode ·
🌐
Microsoft
social.msdn.microsoft.com › Forums › en-US › c4e214a2-6d5d-412f-9c40-90d46f5596ca
modal.show not working | Microsoft Learn
is not working anywhere. I tried to put it into header, in bottom, before jquery declaration, after declaration · <script type="text/javascript"> alert('before'); $(document).ready(function () { alert('after'); $("#login-modal").modal("show"); }); </script>
🌐
YouTube
youtube.com › bytegrad
Bootstrap 5 Modal myModal.show() not working JavaScript (SOLVED) - YouTube
👉 Professional JavaScript Course: https://bytegrad.com/courses/professional-javascript👉 Professional CSS Course: https://bytegrad.com/courses/professional-...
Published   November 18, 2022
Views   10K
🌐
Moodle
moodle.org › mod › forum › discuss.php
Moodle in English: Bootstrap modal.("show") not working in Moodle 4.5 | Moodle.org
I have my plugin in Moodle 4.3+ displaying a modal using JavaScript, $("#exampleModal").modal("show"); it was working perfectly for ages.
🌐
MDBootstrap
mdbootstrap.com › standard › material design for bootstrap 5 & vanilla javascript
Modal not working - Material Design for Bootstrap
If I open the file and remove display: none, the modal shows fine, but I can't close nor trigger it from the button. It seems to be related to the fade. ... Hello, It seems that the <div class="fixed-action-btn"> is causing you problem. If you remove this div the pink button works fine.
Find elsewhere
🌐
Bootstrap
getbootstrap.com › docs › 4.4 › components › modal
Modal · Bootstrap
Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e.
🌐
GitHub
github.com › tabler › tabler › issues › 2517
[BUG] bootstrap Modal Show Via JavaScript Not working · Issue #2517 · tabler/tabler
October 21, 2025 - <script> const myModal = new bootstrap.Modal(document.getElementById('dashboard-modal')); myModal.show(); </script>
Author   sohag1426
🌐
W3Schools
w3schools.com › bootstrap4 › tryit.asp
Modal Events - show.bs.modal
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
Salesforce Developers
developer.salesforce.com › forums
Discussion Forums Migration FAQs | Salesforce Developers
On December 4, 2023, Salesforce Developers discussion forums joined the Trailblazer Community. Learn more with our FAQs!
🌐
Reddit
reddit.com › r/jquery › need help figuring out why my modal won't display
r/jquery on Reddit: Need help figuring out why my Modal won't display
July 20, 2022 -

Hi like the title says, I'm having trouble figuring out why my modal won't display once I click it. Not sure if it's the event listener(or in this case the on.('click') that's not responding.

I would greatly appreciate any advice since I have not been able to solve the problem for two days now.

Here is my link to the source code in codepen

🌐
Team Treehouse
teamtreehouse.com › community › modal-not-displaying-although-i-followed-the-video-exactly
Modal not displaying although I followed the video exactly (Example) | Treehouse Community
December 31, 2022 - I was having the same issue, but was able to resolve it by updating the CSS and JS cdn links used in the workspace to the current Bootstrap version, here: https://getbootstrap.com/docs/5.3/getting-started/download/ The attributes in the version used in the video are missing "bs-". ... <button type="button" class="btn btn-primary btn-lg" data-bs-toggle="modal" data-bs-target="#register">Register Now</button>
Top answer
1 of 9
66

The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open to the to override default scrolling behavior and generates a .modal-backdrop to provide a click area for dismissing shown modals when clicking outside the modal. [source]

How to use via Vanilla JavaScript

Create a modal with a single line of JavaScript:

var myModal = new bootstrap.Modal(document.getElementById('myModal'), options)

source

A quick example:

Copyvar myModal = new bootstrap.Modal(document.getElementById("exampleModal"), {});
document.onreadystatechange = function () {
  myModal.show();
};
Copy<!DOCTYPE html>
<html lang="en">
  <head>

    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, shrink-to-fit=no"
    />


    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
      integrity="sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I"
      crossorigin="anonymous"
    />
    <title>Hello, world!</title>
  </head>
  <body>

    <div
      class="modal fade"
      id="exampleModal"
      tabindex="-1"
      role="dialog"
      aria-labelledby="exampleModalLabel"
      aria-hidden="true"
    >
      <div class="modal-dialog">
        <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">&times;</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>

    <!-- JavaScript and dependencies -->
    <script
      src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
      integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
      crossorigin="anonymous"
    ></script>
    <script
      src="https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
      integrity="sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
      crossorigin="anonymous"
    ></script>

    <script src="./app.js"></script>
  </body>
</html>
Run code snippetEdit code snippet Hide Results Copy to answer Expand

As for your code, you didn't follow the right way to show/toggle a modal in Vanilla JavaScript. Why did you expect myModal.show() to happen while myModal is just a DOM element?

2 of 9
38
  1. Create a new instace of modal and then call show method(see usage points)
Copyvar myModal = new bootstrap.Modal(document.getElementById('exampleModal'))
myModal.show()

ref: https://v5.getbootstrap.com/docs/5.0/components/modal/#options

note: Bootstrap v5 no more uses jquery, instead it uses javascript. lots of changes are there in bootstrap v5, if you are working for a company and willing to use Bootstrap v5 then please go through all the changes.

🌐
GitHub
github.com › orgs › twbs › discussions › 32347
Modal hide function is not working in bootstrap(v5) · twbs · Discussion #32347
There was an error while loading. Please reload this page. ... @XhmikosR comment helped me. For people writing Vue, and using JS to show and hide the modal, you need to add the modal to the data object.