list.js中的可排序列表似乎不起作用

时间:2017-04-26 18:17:56

标签: listjs

我从可排序表的http://listjs.com/examples/table/复制了示例,但它不起作用。谁能告诉我,我做错了什么?

我在<head>

中有这些链接
<link rel="stylesheet" href="/includes/material-design-lite/material.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
      rel="stylesheet">

HTML:

<div id="users">
  <input class="search" placeholder="Search" />
  <button class="sort" data-sort="name">
    Sort by name
  </button>
  <table>
    <!-- IMPORTANT, class="list" have to be at tbody -->
    <tbody class="list">
      <tr>
        <td class="name">Jonny Stromberg</td>
        <td class="born">1986</td>
      </tr>
      <tr>
        <td class="name">Jonas Arnklint</td>
        <td class="born">1985</td>
      </tr>
      <tr>
        <td class="name">Martina Elm</td>
        <td class="born">1986</td>
      </tr>
      <tr>
        <td class="name">Gustaf Lindqvist</td>
        <td class="born">1983</td>
      </tr>
    </tbody>
  </table>

</div>
<script src="//listjs.com/assets/javascripts/list.min.js"></script>

    <script src="/includes/material-design-lite/material.min.js"></script>

JS:

<script type="javascript">
    var options = {
      valueNames: [ 'name', 'born' ]
    };

    var userList = new List('users', options);
    </script>

1 个答案:

答案 0 :(得分:0)

链接list.js时使用绝对URL:

<script src="http://www.listjs.com/assets/javascripts/list.min.js"></script>