首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何在 JQueryUI - 模态表单中禁用背景?

在 JQueryUI 的模态表单中禁用背景,可以通过以下步骤实现:

  1. 在模态表单的 HTML 结构中,为模态表单添加一个自定义的类名,例如 custom-modal
代码语言:html
复制
<div id="my-modal" class="custom-modal">
  <!-- 模态表单内容 -->
</div>
  1. 在 CSS 中,为 custom-modal 类添加以下样式,以禁用背景:
代码语言:css
复制
.custom-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
}
  1. 在 JavaScript 中,使用以下代码初始化模态表单:
代码语言:javascript
复制
$(function() {
  $("#my-modal").dialog({
    modal: true,
    autoOpen: false,
    width: 600,
    height: 400,
    buttons: {
      "确定": function() {
        $(this).dialog("close");
      }
    }
  });

  $("#open-modal-btn").click(function() {
    $("#my-modal").dialog("open");
  });
});

这样,当模态表单打开时,背景将被禁用,用户无法与其他元素进行交互。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

没有搜到相关的沙龙

领券