1

Below code is my popup view...and i want to close popup on clicking close button (X) which is on top of popup...at the bottom of view i have jquery to close the popup..but thats not working..i have popup on another popup..just like parent popup and child popup.and in this case i have to close child popup... Please help me out

<div class="modal-dialog" style="width:1056px" id="pop">
    <div class="modal-content">
       <div class="modal-header">            
            <input type="button" onclick="close()" id="button" value="Close [x]" />          

        </div>
        <div class="modal-body">
            <div class="scroller">
                <table class="display table table-striped table-bordered table-hover" id='tblTicket' cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th>Data</th>                            
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>Data</td>                            
                        </tr>

                    </tbody>
                </table>


                <table class="display table table-striped table-bordered table-hover" id='tblTicket' cellspacing="0" width="100%">
                    <tr>
                        <th>DATA</th>                        
                    </tr>

                    @foreach (var item in Model)
                    {
                        <tr>
                            <td>
                             data 
                            </td>                           
                        </tr>
                    }

                </table>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" language="javascript">
$("#button").click(function () {        
    $("#pop").close
       });
</script>
sachin singh
  • 43
  • 1
  • 1
  • 10
  • Possible duplicate of [Close Bootstrap Modal](https://stackoverflow.com/questions/16493280/close-bootstrap-modal) – Curiousdev May 31 '17 at 06:12

6 Answers6

1

Please check below code :

<script type="text/javascript" language="javascript">

    $("#button").click(function () { 
        $('#pop').modal('toggle');
        $('#pop').modal('hide');
        $('.modal-backdrop').removeClass('modal-backdrop');
        $('.fade').removeClass('fade');
        $('.in').removeClass('in');

        $('html, body').css({
            'overflow': 'auto',
            'height': 'auto'
        });

    });

</script>

Cheers !!

Laxman Gite
  • 2,248
  • 2
  • 15
  • 23
1

Try this code:-

$("#button").click(function () { 

    $('#pop').modal('toggle');

});

mayank
  • 460
  • 3
  • 15
0

Try this

<script type="text/javascript" language="javascript">
$("#button").click(function () {        
    $('#pop').modal('hide');
       });
</script>
Khetesh kumawat
  • 681
  • 7
  • 15
0

you can use something like this instead

<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>

or if you really want to toggle using jquery, you can do this (make sure they have unique IDs

$("#modal1").modal("toggle")

or

$("#modal1").modal("hide")

to just hide it

Luke Meyer
  • 81
  • 8
0

You can simply add a data-dismiss modal to your #button:

$("#button").attr("data-dismiss", "modal");
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
0

if you want to have a function in onclick than you have to write function.

function close(){
   $("#pop").modal("toggle");
 }