jquery jquery-confirm的使用

本文档展示了如何使用jQuery Confirm插件创建一个确认对话框。该对话框会在按钮被点击时出现,询问用户是否确定进行可能导致IT行业科技革命的操作,并提供确定或取消两个选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.css">
  <script src='./jquery-3.4.1.min.js'></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.2/jquery-confirm.min.js"></script>
  <meta charset="utf-8" />
</head>

<body>

  <button class="btn">点击</button>

</body>

<script>

  $(function() {

    $("button.btn").click(function(){

      $.confirm({
        title: '你确定要做这个事情吗',
        content: '你做的事情可能造成IT行业的科技革命',
        buttons: {
          ok: {
            text: '确定',
            btnClass: 'btn-primary',
            action: function() {
              console.log('同意')
            }
          },
          cancel: {
            text: '取消',
            brnClass: 'btn-primary',
            action: function() {
              console.log('取消')
            }
          }
        }
      })

    })


  })
</script>

</html>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值