新创建一个html页面,放弹窗内容,使用$.modal.open()方法弹窗打开,弹窗写在当前页面,当页面比例缩放时遮罩层受影响。
CSS样式
<style>
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 45%;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
</style>
HTML代码
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close" id="close">×</span>
<p>提示</p>
<div style="display: flex;flex-wrap: nowrap;justify-content: center;"><img src="/img/warning1.png" width="25" height="25"/> <p>发文内容文内容文内容文内容</p></div>
<div style="display: flex;flex-wrap: nowrap;justify-content: center;line-height: 45px;">
<input type="checkbox" id="ischeck" style="zoom: 150%;margin-top: 0;">
<div style="margin-left: 5px;">我已知悉,并严格落实!</div>
</div>
<div>
<div style="display: flex;flex-wrap: nowrap;justify-content: center;">
<button type="button" class="btn btn-sm btn-success met2" onclick="submitBtn()">确 定</button>
<button type="button" class="btn btn-sm btn-danger met2" onclick="closeBtn()">关 闭</button>
</div>
</div>
</div>
</div>
JS部分
var xBtn = document.getElementById("close")
xBtn.onclick = function () {
document.getElementById("myModal").style.display = "none";
$('#sendbtn').attr("disabled", true);
$("#ischeck").prop("checked", false);
$.form.reset();
$("#orgname").val("");
$("#sendorgids").val("");
var children = $("#attachmentDiv").children();
children.remove()
}
function submitBtn() {
if ($('#ischeck').is(':checked')) {
document.getElementById("myModal").style.display = "none";
$('#sendbtn').attr("disabled", false);
} else {
$.modal.msgError("请先同意已知悉,并严格落实选项!");
}
}
function closeBtn() {
document.getElementById("myModal").style.display = "none";
$('#sendbtn').attr("disabled", true);
$("#ischeck").prop("checked", false);
$.form.reset();
$("#orgname").val("");
$("#sendorgids").val("");
var children = $("#attachmentDiv").children();
children.remove()
}