- <script>
- // 1、用jquery的on绑定click事件
- // $("#btnExport").on('click',ExportToExcel)
- // 2、用 dom2原生的addEventListener方法绑定事件
- // $("#btnExport")[0].addEventListener("click",ExportToExcel,false);
- function ExportToExcel() {
- $("#tableExcel").table2excel({
- exclude : ".noExl", //过滤位置的 css 类名
- filename : "表格导出", //文件名称
- name: "Excel Document Name.xlsx",
- exclude_img: false,//是否导出图片 false导出
- exclude_links: true,//是否导出链接 false导出
- exclude_inputs: true//是否导出输入框的值 true导出
- });
- }
- </script>
复制代码不好意思,刚看到帖子回复。以上两种方法都行。我也不知道为啥直接标签绑定dom0事件为啥不生效。应该是加载先后问题。先工作了。