當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringBoot中使用thymeleaf时点击按钮触发事件失败
生活随笔
收集整理的這篇文章主要介紹了
SpringBoot中使用thymeleaf时点击按钮触发事件失败
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
場景
在SpringBoot項目中使用thymeleaf模板時按鈕的點擊事件沒法觸發。
需要用到jquery的delegate()函數。
delegate()函數用于為指定元素的一個或多個事件綁定事件處理函數。
實現
html代碼:
<button id="uploladBtn" class="btn btn-info mt-2" type="button" ><i class="fa fa-reply"></i>上傳</button>引入js文件:
th:replace="layout/layout(title='收貨單數據',cssPaths='/public/css/plugins/jsTree/style.min.css',jsPaths='/modular/receiveOrder/wmsReceiveOrder.js')">js代碼:
$(document).delegate("button#uploladBtn", "click", function () {uploadExcel();});這樣就能在js文件中通過button的id觸發點擊事件。
總結
以上是生活随笔為你收集整理的SpringBoot中使用thymeleaf时点击按钮触发事件失败的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringBoot中使用thymele
- 下一篇: Unknown system varia