Click here to Skip to main content
15,881,850 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a div I want to open it as a popup using Jquery but its not working.
I am trying this from some example.I have followed the steps as per The Steps in the Example's video.Below are the complete code given.

What I have tried:

<!DOCTYPE html>
<html>
<head>
    <title></title>
	<meta charset="utf-8" />
    <link href="Content/bootstrap.min.css" rel="stylesheet" />
</head>
<body style="padding-top:20px">
    <div class="col-md-10 col-md-offset-1">
        <div class="well">
            <table class="table table-bordered">
                <thead>
                    <tr class="success">
                        <td colspan="2">
                            New User Registration
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>
                            Email
                        </td>
                        <td>
                            <input type="text" id="textEmail" placeholder="Enter Email" />
                        </td>

                    </tr>
                    <tr>
                        <td>
                            Password
                        </td>
                        <td>
                            <input type="text" id="textpassword" placeholder="Enter Password" />
                        </td>

                    </tr>
                    <tr>
                        <td>
                            Coinfirm Password
                        </td>
                        <td>
                            <input type="text" id="textCoinfirmPassword" placeholder="Enter  Coinfirm Password" />
                        </td>

                    </tr>
                    <tr class="success">
                        <td>
                            <input type="button" id="btnRegister" class="btn btn-success" value="Register" />
                        </td>
                    </tr>
                </tbody>
            </table>
            <div class="modal fade" tabindex="-1" id="successModal" data-keyboard="false" data-backdrop="static">
                <div class="modal-dialog modal-sm">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dissmiss="modal">
                                ×
                            </button>
                            <h4>success</h4>
                        </div>
                        <div class="modal-body">
                            <h2>Registration Successful</h2>
                        </div>
                        <div class="modal-footer">
                            <button type="button" data-dissmiss="modal" class="btn btn-success">
                                Close
                            </button>
                        </div>
                    </div>

                </div>

            </div>
        </div>

    </div>
    <script src="Scripts/bootstrap.min.js"></script>

    <script src="Scripts/jquery-1.10.2.min.js"></script>
    
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnRegister").click(function () {
               // alert('hiiiii');
                $("#successModal").modal('show');
            });
        });

    </script>
</body>
</html>
Posted
Updated 17-Aug-17 6:56am
v3
Comments
Karthik_Mahalingam 17-Aug-17 0:47am    
jquery file reference added twice
Member 10310320 17-Aug-17 11:14am    
Plz check the updated code I have tried this as well.

1 solution

'modal' function is a jQuery extension added by Bootstrap, but you didn't included the Bootstrap JavaScript...
 
Share this answer
 
Comments
Member 10310320 17-Aug-17 11:08am    
I tried with Bootstrap JavaScript as well Its not working.
Richard Deeming 17-Aug-17 12:45pm    
Your latest update doesn't include the Bootstrap Javascript file.

Update your question to show the version that does include it.
Member 10310320 17-Aug-17 13:07pm    
Plz see now
Richard Deeming 17-Aug-17 13:09pm    
You need to include jQuery before the Bootstrap Javascript file.

If you check the browser's developer console, you'll see an error telling you that you've got them the wrong way round.
Member 10310320 17-Aug-17 14:21pm    
Thanks its working as expected.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900