swal({
        title: "Log In to Continue",
        html: true,
        text: "Username: <input type='text'><br>Password: <input type='password'>",
        type:"input"
});


javascript - Sweet Alert是否不占用两个输入区域?-LMLPHP

最佳答案

 swal({
   title: 'Multiple inputs',
     html:
   '<input id="swal-input1" class="swal2-input" autofocus>' +
  '<input id="swal-input2" class="swal2-input">',
   preConfirm: function() {
   return new Promise(function(resolve) {
    if (result) {
      resolve([
        $('#swal-input1').val(),
        $('#swal-input2').val()
        ]);
      }
    });
   }
   }).then(function(result) {
 swal(JSON.stringify(result));
           })

09-17 02:01