gpt4 book ai didi

javascript - Chrome 中带有文本框的 sweetalert 对话框

转载 作者:行者123 更新时间:2023-11-27 23:56:58 25 4
gpt4 key购买 nike

我在使用 Chrome 中带有文本字段的 sweetalert 对话框时遇到问题。它在 mozila 中工作得很好,但在 chrome 中不起作用。警报框可以工作,但不允许在 texbox 中输入值。

下面是jquery

function sendmail(val){
swal({
title: "Send E-Mail",
text: "<input type='email' class='form-control' name='email' id='email'/>",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Send",
html: true,
closeOnConfirm: false
},
function (isConfirm) {
if (isConfirm) {
var email = $("#email").val();
var dataString = 'email=' + email + '&id=' + val;
$.ajax({
type: "POST",
url: "../class/sendmail.php",
data: dataString,
cache: false,
success: function (result) {
swal("sent!", "Your Mail has been sent.", "success");
}
});
}
});}

最佳答案

我认为这是两件事,首先你使用了 Sweet Alert 的输入错误。您想要更改要输入的甜蜜警报的类型。

swal({   
title: "An input!",
text: "Write something interesting:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
animation: "slide-from-top",
inputPlaceholder: "Write something" },
function(inputValue){
if (inputValue === false) return false;
if (inputValue === "") {
swal.showInputError("You need to write something!");
return false
}
swal("Nice!", "You wrote: " + inputValue, "success");
});

这取自 sweetalert Website 上的示例

此外,当您在 DOM 加载后添加 input#email 时,您需要使用类似 jQuery 的 .on() 的东西。功能。

关于javascript - Chrome 中带有文本框的 sweetalert 对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32181135/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com