简体   繁体   English

我如何添加关闭按钮并调整 jQuery 模态的大小

[英]How i can add a close button and resize the jQuery modal

I have the following jQuery modal code:-我有以下 jQuery 模态代码:-

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


            });

            $(function () {

                $(document).on('click', 'a[data-dismiss]', function (e) {

                    if ($(this).attr('data-reload') == 'no') {
                        $(this).parents('.modal').first().modal('hide');

                    }
                });


            });
            });
    </script>

and the following HTML to show the modal:-和以下 HTML 显示模态:-

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

 <a data-modal='' href="/home/bookappointment" title="Detail"> Book Appointment </a>

but currently the modal will only occupy a very small part of the screen + i can not close the modal popup.但目前模态只会占据屏幕的很小一部分+我无法关闭模态弹出窗口。 so can anyone advice how i can expand the modal height and width + add a close button to it?那么任何人都可以建议我如何扩展模态高度和宽度+为其添加关闭按钮吗?

You can use data-dismiss="modal" like this.您可以像这样使用 data-dismiss="modal" 。

<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为模式框(灯箱)Typo3扩展添加关闭按钮? - How can I add a close button to the Modal Box (Lightbox) Typo3 extension? 如何关闭我编写的jQuery模态? - How can I close this jQuery modal I wrote? 如何在反应模态中将关闭按钮放置在模态 window 之外? - How can I place close button outside of modal window in react-modal? 如何使用最后弹出的模式上的关闭按钮关闭多个引导程序模式 - How can I close multiple bootstrap modals with the close button on the last popped modal 如何在 JQuery Datepicker 中调整下一个和上一个按钮的大小? - How can i resize the next and previous button in JQuery Datepicker? 我想在单击添加按钮后关闭模式 - i want to close the modal after i click add button 单击“添加产品”按钮时如何关闭模态 window? - How do I close the modal window in react when clicking on the Add product button? 如何添加关闭按钮以弹出窗口 - How can I add a close button to pop up window 如何在 html 视频弹出窗口中添加关闭按钮? - How can I add a close button to a html video popup? 如何通过模拟模态的关闭按钮使用jquery关闭模态窗口 - How to use jquery to close modal window, by emulating the modal's close button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM