如果我在模式弹出窗口之外单击,如何关闭/隐藏模式弹出窗口

时间:2020-07-28 11:56:36

标签: javascript html jquery twitter-bootstrap

我有以下jQuery代码显示模式弹出窗口:-

$(document).ready(function () {
            
            $(function () {
                $.ajaxSetup({ cache: false });
                $(document).on('click', 'button[data-modal]', function (e) {
                    $('#myModalContent').css({ "margin": "5px", "max-height": screen.height * .82, "max-width": screen.height * .82, "overflow-y": "auto" }).load($(this).attr("data-url"), function () {
                        $('#myModal').modal({
                            height: 1000,
                            width: 2200,
                            resizable: true,
                            keyboard: true,
                            backdrop: 'static',
                            draggable: true
                        }, 'show');
                       
                    });
                    return false;
                });


            });
          });

和以下HTML:-

 <div id='myModal' class='modal fade in'>
     <div class="modal-dialog">
           <div class="modal-content">
               <div id='myModalContent'></div>
           </div>
     </div>
 </div>

当前,当我在模式弹出窗口之外单击时,模式弹出窗口将不会被隐藏/关闭..所以我可以将此行为强加给我的jQuery模式弹出窗口吗?

1 个答案:

答案 0 :(得分:2)

您需要删除backdrop: 'static',

相关问题