有条件的甜蜜警报输入

时间:2018-12-27 12:38:07

标签: javascript sweetalert

我该如何为输入字段中输入的字符串设置条件,例如,如果userName等于'xyz',则为swal(“ welcome!”)否则为swal(“下次更好”)?到目前为止,我在下面给出了我的代码。

> swal({
         title: "Proceeding...",
         content: {
                  element: "input",
                  attributes: {
                      placeholder: "Type up your userName",
                      type: "userName",
                  },              
                },
       });

1 个答案:

答案 0 :(得分:0)

您可以:

Array
(
    [0] => stdClass Object
        (
            [id] => 1
        )

)
Array
(
    [0] => stdClass Object
        (
            [id] => 2
        )

    [1] => stdClass Object
        (
            [id] => 2
        )

)

引用:https://sweetalert.js.org/guides/#using-dom-nodes-as-content