css确认弹窗修改选项内容
要修改确认弹窗的选项内容,你可以使用JavaScript来实现。下面是一个示例代码:
HTML:
<button onclick="showConfirmationDialog()">点击弹窗</button>
<div id="confirmationDialog" class="hide">
<h3>确认弹窗</h3>
<p id="confirmationMessage">你确定要执行此操作吗?</p>
<button onclick="confirmAction()">确认</button>
<button onclick="cancelAction()">取消</button>
</div>
CSS:
.hide {
display: none;
}
JavaScript:
function showConfirmationDialog() {
var dialog = document.getElementById("confirmationDialog");
dialog.classList.remove("hide");
}
function confirmAction() {
// 在这里执行确认操作
// 关闭弹窗
var dialog = document.getElementById("confirmationDialog");
dialog.classList.add("hide");
}
function cancelAction() {
// 在这里执行取消操作
// 关闭弹窗
var dialog = document.getElementById("confirmationDialog");
dialog.classList.add("hide");
}
这段代码创建了一个包含确认弹窗的按钮。当点击按钮时,showConfirmationDialog函数会将弹窗显示出来。弹窗中包含一个确认消息和确认和取消按钮。当点击确认按钮时,confirmAction函数会执行确认操作,并关闭弹窗。当点击取消按钮时,cancelAction函数会执行取消操作,并关闭弹窗。
你可以根据需要修改弹窗中的文本内容,只需修改HTML中的<p>标签中的文本内容即可
原文地址: https://www.cveoy.top/t/topic/hXjX 著作权归作者所有。请勿转载和采集!