在 JQueryUI 的模态表单中禁用背景,可以通过以下步骤实现:
custom-modal
。<div id="my-modal" class="custom-modal">
<!-- 模态表单内容 -->
</div>
custom-modal
类添加以下样式,以禁用背景:.custom-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 999;
}
$(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");
});
});
这样,当模态表单打开时,背景将被禁用,用户无法与其他元素进行交互。
领取专属 10元无门槛券
手把手带您无忧上云