Sweet Alert带有文本框的Modal

发布时间:2024-08-15 13:20:55    发布者:文昌文城莱奥网络技术工作室    浏览次数:319

 swal({
                        title: '请输入手机号码',
                        html: '<br><input class="form-control" placeholder="Input Something" id="enterPhoneNumber">',
                        content: {
                            element: "input",
                            attributes: {
                                placeholder: "",
                                type: "text",
                                id: "enterPhoneNumber",
                                className: "form-control"
                            },
                        },
                        buttons: {
                            cancel: {
                                visible: true,
                                className: 'btn btn-danger'
                            },
                            confirm: {
                                className: 'btn btn-success'
                            }
                        },
                    }).then(function(result) {
                        console.log(result);

                        if (result == null) {
                            // 用户点击了“取消”按钮
                            swal("", "You canceled the input", "info");

                        } else {
                            // 用户点击了“确定”按钮
                            swal("", "You entered: " + $('#enterPhoneNumber').val(), "success");


                        }
                    });