TableTools的基本用法示例不起作用

时间:2014-08-13 00:29:42

标签: javascript html css tabletools

在我的Visual Studio项目中,我在这里复制了确切的代码:http://datatables.net/release-datatables/extensions/TableTools/examples/simple.html


我将项目中的两个css文件保存为style1.cssstyle2.css

我将三个js文件保存为script1.jsscript2.jsscript3.js

然后,我将custom.js文件作为:

$(document).ready(function() {
    $('#example').DataTable( {
        dom: 'T<"clear">lfrtip'
    } );
} );

最后,我的index.html看起来像这样:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="style1.css" />
    <link rel="stylesheet" type="text/css" href="style2.css" />
    <script type="text/javascript" src="custom.js"></script>
    <script type="text/javascript" src="script1.js"></script>
    <script type="text/javascript" src="script2.js"></script>
    <script type="text/javascript" src="script3.js"></script>
</head>
<body>
    <!--inserted exact copy of html table-->
</body>

根据我的理解,该页面的代码应该按原样运行。 但是,它似乎根本不起作用。

  • 无格式化
  • 看不到“复制”,“csv”...按钮

如何安排我的所有文件/代码以使其有效?

我对此很新;任何帮助表示赞赏!

1 个答案:

答案 0 :(得分:0)

您需要添加对jquery库和TableTools插件的引用。在显示示例的页面上,您将看到解释您需要这三个库的文本。

将它放在其他js文件之前。

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.dataTables.js"></script>
<script type="text/javascript" src="dataTables.tableTools.js"></script>
相关问题