Javascript – 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.

<form id="myform" class="form-wizard">
    <h2 class="form-wizard-heading">BootStap Wizard Form</h2>
    <input type="text" value=""/>
    <input type="submit"/>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Modal header</h3>
    <div class="modal-body">
        <p>One fine body…</p>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <button class="btn btn-primary">Save changes</button>


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

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

    // $("#results").text(data);


Best Solution

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: