如何改变sweetalert按钮文字?

Dip*_*ase 6 jquery sweetalert

我想用'选择患者'更改'确定'按钮,将'取消'更改为'速度包'.我怎样才能做到这一点?

swal({
  text: "Start new case by",
  buttons: true,
  confirmButtonText: "Select Patient?",
  cancelButtonText: "Speed Case?",      
});
Run Code Online (Sandbox Code Playgroud)

小智 11

这是答案

 swal({
            title: "Are you sure?",
            text: "you want to Cancel Operation!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#DD6B55',
            confirmButtonText: 'Yes, I am sure!',
            cancelButtonText: "No, cancel it!",
            closeOnConfirm: false,
            closeOnCancel: false
        },
Run Code Online (Sandbox Code Playgroud)

希望它对你有用


Roh*_*IUC 8

swal({
  text: "Start new case by",
  buttons: ["Select Patient?", "Speed Case?"],
});
Run Code Online (Sandbox Code Playgroud)

  • 这对我不起作用,也许是因为有多个 Sweet-alert 分支命名相同(或几乎相同)的东西:sweetalert2。也许有些人仍在使用第 1 版,它 _ 可能_ 也有多个分叉......我不知道。如果这对您也不起作用,请尝试 [this one](/sf/answers/3431919781/),这对我有用。 (2认同)

小智 8

您可以使用这种方法

swal({
  text: "Start new case by",
  showCancelButton: true,
  confirmButtonText: "Select Patient?",
  cancelButtonText: "Speed Case?",     
  title: 'Title'
});

Run Code Online (Sandbox Code Playgroud)