SpringBoot中使用thymeleaf时点击按钮触发事件失败

场景

在SpringBoot项目中使用thymeleaf模板时按钮的点击事件没法触发。

需要用到jquery的delegate()函数。

delegate()函数用于为指定元素的一个或多个事件绑定事件处理函数。

实现

html代码:

引入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)