简体   繁体   English

Javascript代码未在模式关闭时执行

[英]Javascript code not executing on modal close

I have a modal with a form that I try to clear when I close the Modal. 我有一个模态,该模态在我关闭模态时会尝试清除。 I have 2 different Modal on 2 different pages. 我在2个不同的页面上有2个不同的Modal。 I use the same Javascript to clear them. 我使用相同的Javascript清除它们。 On the User page, it works, but not on the AddProject page. 在“用户”页面上,它可以工作,但在“ AddProject”页面上,它不能工作。 Do you know why and how I can fix this? 您知道为什么以及如何解决这个问题吗?

$('#addProjectModal').on('hidden.bs.modal', function () {
    $('#addProjectModal form')[0].reset();
});

$('#addadminprofile').on('hidden.bs.modal', function () {
   $('#addadminprofile form')[0].reset();
});
<!-- Modal -->
   <div class="modal fade" id="addProjectModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
     <div class="modal-dialog modal-xl" role="document">
       <div class="modal-content">
         <div class="modal-header">
           <h5 class="modal-title" id="exampleModalLabel">Ajouter un projet</h5>
           <button type="button" class="close" data-dismiss="modal" aria-label="Close">
             <span aria-hidden="true">&times;</span>
           </button>
         </div>
         <form action="suiviProjet.php" method="POST">
<!-- Modal -->
   <div class="modal fade" id="addadminprofile" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
     <div class="modal-dialog modal-xl" role="document">
       <div class="modal-content">
         <div class="modal-header">
           <h5 class="modal-title" id="exampleModalLabel">Add Admin</h5>
           <button type="button" class="close" data-dismiss="modal" aria-label="Close">
             <span aria-hidden="true">&times;</span>
           </button>
         </div>
         <form action="users.php" method="POST">

我发现了为什么一个代码在运行,而不是其他代码...我必须清除缓存,这很好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM