jquery赢得了在脚本上调用插件的火警

时间:2015-05-18 16:08:53

标签: javascript jquery excel

我有我试图运行的jquery脚本。

从html表中下载到excel文件中的数据。

http://www.jqueryscript.net/table/Export-Html-Table-To-Excel-Spreadsheet-using-jQuery-table2excel.html

当我尝试运行按钮时,它会在此调用脚本中显示错误:

<script>
$(".dataTable_wrapper button").click(function(){
  $("#table2excel").table2excel({
    // exclude CSS class
    exclude: ".noExl",
    name: "Excel Document Name"
  }); 
});
</script>

错误发生在第二行: &#34;未捕获类型错误:$(....)table2excel不是函数&#34;

3 个答案:

答案 0 :(得分:2)

您可能以错误的顺序导入库。在导入任何jquery插件之前尝试导入jquery。

答案 1 :(得分:1)

您是否正确链接了js插件?在de exetucion代码之前? 尝试包装这样的函数:

<script>
$(function(){
    $(".dataTable_wrapper button").click(function(){
      $("#table2excel").table2excel({
        // exclude CSS class
        exclude: ".noExl",
        name: "Excel Document Name"
      }); 
    });
});
</script>

答案 2 :(得分:0)

毕竟这很简单。我的脚本是:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="src/jquery.table2excel.js"></script>

当我将位置更改为实际网址时,即:

<script src="myawesomesite.co.uk/wp-content/classes/assets/js/jquery.table2excel.js"></script>

感谢您的支持!