How to open a Bootstrap modal window using jQuery?

How to open a Bootstrap modal window using jQuery?

I’m using Twitter Bootstrap modal window functionality. When someone clicks submit on my form, I want to show the modal window upon clicking the “submit button” in the form.

BootStap Wizard Form

$(‘#myform’).on(‘submit’, function(ev) {
show: ‘false’

var data = $(this).serializeObject();
json_data = JSON.stringify(data);

// $(“#results”).text(data);



Solution 1:

Bootstrap has a few functions that can be called manually on modals:


You can see more here: Bootstrap modal component

Specifically the methods section.

So you would need to change:

    show: 'false'



If you’re looking to make a custom popup of your own, here’s a suggested video from another community member:

Solution 2:

In addition you can use via data attribute

<button type="button" data-toggle="modal" data-target="#myModal">Launch modal</button>

In this particular case you don’t need to write javascript.

You can see more here:

Solution 3:

Most often, when $('#myModal').modal('show'); doesn’t work, it’s caused by having included jQuery twice. Including jQuery 2 times makes modals not to work.

Remove one of the links to make it work again.

Furthermore, some plugins cause errors too, in this case add


Solution 4:

Just call the modal method(without passing any parameters) using jQuery selector.

Here is example:


Solution 5:

If you use links’s onclick function to call a modal by jQuery, the “href” can’t be null.

For example:

... ...
<a href="" onclick="openModal()">Open a Modal by jQuery</a>
... ...
... ...
<script type="text/javascript">

function openModal(){


The Modal can’t show.
The right code is :

<a href="#" onclick="openModal()">Open a Modal by jQuery</a>

Solution 6:

Check out the complete solution here:

Make sure to put libraries in required order to get result:

1- First bootstrap.min.css 2- jquery.min.js 3- bootstrap.min.js

(In other words jquery.min.js must be call before bootstrap.min.js)

    <link rel="stylesheet" href="">

<script src="">

 <script src=""></script>