我是 Laravel 的新手,我正在嘗試使用關閉和添加按鈕制作模態。當我單擊關閉時,會顯示一個小對話框詢問您是否真的要退出模態,但是當我單擊確定時,它不會關閉模態。有人知道為什么是這樣嗎?
我的模態:
<div class="modal-footer">
<button type="button" class="btn btn-secondary" onclick ="return confirm('Do you really want to quit?');" data-backdrop="static">Close</button>
<button type="submit">Add</button>
</div>
uj5u.com熱心網友回復:
return confirm('Do you really want to quit?');什么都不做。您應該使用 jQuery 來隱藏模式。
如果您真的想使用confirm,您可以使用以下行內命令或使用單獨的函式。
假設模態的id是“test_modal”,那么:
<div class="modal-footer" id="test_modal">
<button type="button" class="btn btn-secondary"
onclick ="confirm('Do you really want to quit?')? $('#test_modal').modal('hide') : false"
data-backdrop="static">Close</button>
<button type="submit">Add</button>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/371872.html
