我遇到了带有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");
}
});
}
});}
答案 0 :(得分:1)
我认为这是两回事,首先你使用甜蜜警报输入错误。您想要将甜蜜警报的类型更改为输入。
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加载后添加输入#mail时,您需要使用类似jQuery的.on()功能。