关闭Bootstrap的modal后,重新打开还会有input里上传的file解决
生活随笔
收集整理的這篇文章主要介紹了
关闭Bootstrap的modal后,重新打开还会有input里上传的file解决
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
場景
點擊modal模態框,有一個file類型的input,上傳完文件后,將其關閉,
再次打開還會有上傳的文件。
代碼:
?<div class="modal inmodal" id="apImportModel" tabindex="-1" role="dialog"? aria-hidden="true"><div class="modal-dialog" id="apImportDiv" th:fragment="apImportDiv"><div class="modal-content animated fadeIn"><button type="button" class="close" onclick="return Testclose();" id="closeUploadBtn"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button><form? class="dropzone"? id="dropzoneForm" enctype="multipart/form-data"><div class="fallback"><input name="file" value="1M以內的Excel文件" type="file" id="file_id"? accept=".xls,.xlsx" onchange="fileChange(this);" /></div></form><button id="uploladBtn" class="btn btn-info mt-2" type="button" onclick="return uploadExcel()"><i class="fa fa-reply"></i>上傳</button><button id="parseBtn" class="btn btn-info mt-2" type="button" onclick="return parseExcel()"><i class="fa fa-reply"></i>導入</button></div></div></div>解決
在關閉modal的js方法里面:
//關閉窗口操作 function Testclose(){$("#apImportModel").modal('hide');$("#file_id").val(null);return false; }關掉modal并清理掉input。
總結
以上是生活随笔為你收集整理的关闭Bootstrap的modal后,重新打开还会有input里上传的file解决的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Bootstrap模态框(modal)显
- 下一篇: SpringBoot中整合使用Freem