show.bs.modal 在调用 show 方法后触发。
shown.bs.modal 当模态框对用户可见时触发(将等待 CSS 过渡效果完成)。
hide.bs.modal 当调用 hide 实例方法时触发。
hidden.bs.modal 当模态框完全对用户隐藏时触发。
上述参考:https://blog.csdn.net/wn464319127/article/details/50432965
运用code
<script> // 当模態對話框彈出時清除上次檢測情況 $(function(){ $("#add_location_modal").on('show.bs.modal',function(){ var location_obj = $("#add_location_input"); var div_obj = location_obj.closest('div'); var span_obj = location_obj.next('span'); // location_obj.focus(); location_obj.val(""); div_obj.removeClass("has-error"); div_obj.removeClass("has-success"); span_obj.html(""); }); }); </script>