當(dāng)前位置:
首頁 >
关闭Bootstrap的modal后,重新打开还会有input里上传的file解决
發(fā)布時(shí)間:2025/3/19
29
豆豆
生活随笔
收集整理的這篇文章主要介紹了
关闭Bootstrap的modal后,重新打开还会有input里上传的file解决
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
場景
點(diǎn)擊modal模態(tài)框,有一個(gè)file類型的input,上傳完文件后,將其關(guān)閉,
再次打開還會有上傳的文件。
代碼:
?<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以內(nèi)的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>導(dǎo)入</button></div></div></div>解決
在關(guān)閉modal的js方法里面:
//關(guān)閉窗口操作 function Testclose(){$("#apImportModel").modal('hide');$("#file_id").val(null);return false; }關(guān)掉modal并清理掉input。
總結(jié)
以上是生活随笔為你收集整理的关闭Bootstrap的modal后,重新打开还会有input里上传的file解决的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Bootstrap模态框(modal)显
- 下一篇: IDEA中安装Free Mybatis