1
私はインターネットで研究しようとしたが、私は彼/彼女はswalの中にHTMLを作ることを見て、私はコードをコピーし、それをonclick機能の中に入れた。私がそれをクリックするたびに、swalはそこにありますが、入力フィールドはありません。問題は入力フィールドが表示されない原因は何ですか?onclick関数でswal(sweetAlert内)を使用して2つの入力フィールドを挿入するにはどうすればよいですか?
<a id = "a" onclick = "divFunction()">Forgot Password</a>
私は同じ問題を持っていた
<script type="text/javascript">
function divFunction(){
//Some code
swal({
title: 'Multiple inputs',
html: true,
text: '<h2>Login details for waybill generation</h2>'+
'<input id="swal-input1" class="swal2-input" autofocus placeholder="User ID">' +
'<input id="swal-input2" class="swal2-input" placeholder="Password">',
preConfirm: function() {
return new Promise(function(resolve) {
if (result) {
resolve([
$('#swal-input1').val(),
$('#swal-input2').val()
]);
}
});
}
}).then(function(result) {
swal(JSON.stringify(result));
})
}
</script>