如何在js变量中保存甜蜜警报提示

时间:2018-08-16 06:40:07

标签: sweetalert

我有这个代码

var pass = prompt("Please enter your password:", "");

我想通过Sweet Alert发出此提示并将其保存在可变传递中。到目前为止,我已经做到了,但是我不知道如何将其保存到变量中。

swal({
content: {
element: "input",
attributes: {
 placeholder: "Type your password",
  type: "password",
},
},
});

1 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

var pass = null;

swal({
    content: {
        element: "input",
        attributes: {
            placeholder: "Type your password",
            type: "password",
        }
    }
})
.then(function(value) {
    pass = value;
});