有沒有一種方法可以禁用我提交按鈕的每個表單提交。當用戶在應用程序的任何地方提交表單。禁用全局jquery提交按鈕的方法
-1
A
回答
1
添加選擇這樣$('input[type=submit]')
。而應用禁用特性真正與prop()
功能
$(document).ready(function() {
$('input[type=submit],button[type=submit]').prop('disabled', true);
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="submit" class="qu-more" value="Add">
<button type="submit">Add</button>
1
使用ATTR選擇:
$('[type="submit"], form button').attr('disabled','disabled');
https://jsfiddle.net/mlescaudron/etsnutqo/1/
編輯
Thor Rory about button。
+2
不要忘記,沒有'type'屬性的'
+0
不幸的是,你的'表單按鈕'選擇器不是很正確,因爲它會選擇'
1
爲了達到這個目的,你可以使用jQuery的:submit
選擇器。與其他答案一樣,您可以使用屬性選擇器,但這是有缺陷的,因爲沒有type
屬性的按鈕在默認情況下將成爲提交按鈕。
$(':submit').prop('disabled', true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<button>Empty button</button> <!-- this is a submit button too! -->
<button type="submit">Submit button</button>
<button type="button">Basic button</button>
</form>
相關問題
- 1. jquery禁用提交按鈕
- 2. jquery 1.8禁用/啓用提交按鈕
- 3. 禁用按鈕提交點擊jquery
- 4. jQuery提交失敗後禁用按鈕
- 5. 如何禁用jQuery提交按鈕?
- 6. 提交後禁用按鈕
- 7. 僅提交按鈕+禁用提交w/jQuery
- 8. jquery對話框提交按鈕無法控制啓用/禁用
- 9. 最簡單的方法來禁用按鈕提交表單?
- 10. 回發後禁用所有提交按鈕的最佳方法
- 11. 規範的jQuery方法來動態啓用/禁用表單提交按鈕
- 12. 禁止提交表單按鈕提交
- 13. 僅當javascript禁用時,禁止提交事件/提交按鈕
- 14. 禁用提交按鈕的指令
- 15. Jquery方法不禁用按鈕
- 16. 禁用再啓用提交按鈕
- 17. JQuery的啓用/禁用提交按鈕在IE7
- 18. jQuery禁用或啓用基於日期的提交按鈕
- 19. 的按鈕信息更簡單的方法提交(安全)
- 20. ASP.NET如何禁用按鈕提交?
- 21. 後點擊禁用提交按鈕
- 22. 禁用演示提交按鈕
- 23. 禁用提交按鈕JavaScript時觸發
- 24. 禁用表單提交按鈕
- 25. 禁用多次提交按鈕
- 26. Popup MSG和禁用提交按鈕
- 27. 正確禁用提交按鈕
- 28. 禁用提交按鈕直到驗證
- 29. 禁用ASP.NET嚮導模板中的jQuery提交按鈕
- 30. 的jQuery - 禁用/模擬「進入」行爲提交按鈕
不要忘記了''
但我想要在整個應用程序中執行所有提交方法的全局方法。我怎樣才能做到這一點 ? –
你可以在你的'main.js'文件中添加這個js並在'document.ready'函數中添加這行。就像看到更新的答案 – prasanth