我有提交按鈕(引導程式),我將一些資料從輸入欄位提交到我的 PHP 查詢。在用戶單擊該按鈕后,我已向此提交按鈕添加了一個加載微調器。由于我已將微調器 ID 添加到按鈕,因此“必需”的 HTML 屬性不再起作用。它不再向用戶指示丟失的資訊。
例子:
$(document).ready(function() {
$("#load").click(function() {
// disable button
$(this).prop("disabled", true);
// add spinner to button
$(this).html(
`<i ></i> Loading`
);
$("#save").submit();
});
});
<form method="post" action="" id="save">
<input class="input" name="passwort" type="password" placeholder="Enter your password here" required> </input>
<button type="submit" class="btn btn-lg btn-primary" id="load"> Save </button>
</form>
uj5u.com熱心網友回復:
也許你應該聽提交事件而不是點擊?
$(document).ready(function() {
$("#save").submit(function(e) {
// disable button
$('#load').prop("disabled", true);
// add spinner to button
$('#load').html(
`<i ></i> Loading`
);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form method="post" action="" id="save">
<input class="input" name="passwort" type="password" placeholder="Enter your password here" required> </input>
<button type="submit" class="btn btn-lg btn-primary" id="load"> Save </button>
</form>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/365651.html
標籤:javascript php html 按钮 旋转器
上一篇:無法使用xml和資料系結啟用按鈕
