弹出确认框

confirm
if(confirm("是否确认?")){===},  {===}
如果你使用的是 Bootstrap 架,可以使用 Bootstrap 的 Modal 组件来实现弹出确认。以下是一个简单的示例: ```html <!-- 引入 Bootstrap 样式和 JavaScript --> <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css"> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script> <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script> <!-- 一个按钮,点击弹出确认 --> <button class="btn btn-primary" data-toggle="modal" data-target="#confirmModal">点击弹出确认</button> <!-- 确认的 HTML 代码 --> <div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="confirmModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="confirmModalLabel">确认标题</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> 确认内容 </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button type="button" class="btn btn-primary">确认</button> </div> </div> </div> </div> ``` 这个示例中,我们定义了一个按钮,点击这个按钮会弹出一个确认确认的 HTML 代码在 `div` 元素中,其中 `id` 属性为 `confirmModal`,和按钮中的 `data-target` 属性相对应。确认中包含一个标题、一个内容和两个按钮,分别为“取消”和“确认”。点击“取消”按钮或者确认外的区域都会关闭确认,点击“确认”按钮会执行默认行为。你可以在“确认”按钮的 `onclick` 事件中编写你需要执行的代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值