JQuery TableSort 不适用于 JQuery floatThead
JQuery TableSort doesn't work with JQuery floatThead
我有下面的 MCVE 示例 table 来自 tablesorter@github
单击 table header 对 table 进行排序。当我添加此示例中注释的这一行 $('table#myTable').floatThead();
时,它将停止工作。
知道问题是什么以及如何解决吗?
<html lang="en">
<head>
<title>JQuery table sorter with JQuery floatThead MCVE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://rawgit.com/christianbach/tablesorter/master/jquery.tablesorter.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.1.2/jquery.floatThead.min.js"></script>
</head>
<body>
<table id="myTable" class="tablesorter" border=1>
<thead>
<tr><th>Last Name</th><th>First Name</th><th>Email</th><th>Due</th><th>Web Site</th></tr>
</thead>
<tbody>
<tr><td>Smith</td><td>John</td><td>jsmith@gmail.com</td><td>.00</td>
<td>http://www.jsmith.com</td></tr>
<tr><td>Bach</td><td>Frank</td><td>fbach@yahoo.com</td><td>.00</td>
<td>http://www.frank.com</td></tr>
<tr><td>Doe</td><td>Jason</td><td>jdoe@hotmail.com</td><td>0.00</td>
<td>http://www.jdoe.com</td></tr>
<tr><td>Conway</td><td>Tim</td><td>tconway@earthlink.net</td><td>.00</td>
<td>http://www.timconway.com</td></tr>
</tbody>
</table>
<script type="text/javascript">
//$('table#myTable').floatThead();
$(document).ready(function() { $("#myTable").tablesorter(); }
);
</script>
</body>
</html>
我偶然发现了一个非常简单的解决方案:顺序很重要!只需添加 $('table#myTable').floatThead();
AFTER 函数 tablesorter()
已被调用。
<html lang="en">
<head>
<title>JQuery table sorter with JQuery floatThead MCVE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://rawgit.com/christianbach/tablesorter/master/jquery.tablesorter.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.1.2/jquery.floatThead.min.js"></script>
</head>
<body>
<table id="myTable" class="tablesorter" border=1>
<thead>
<tr><th>Last Name</th><th>First Name</th><th>Email</th><th>Due</th><th>Web Site</th></tr>
</thead>
<tbody>
<tr><td>Smith</td><td>John</td><td>jsmith@gmail.com</td><td>.00</td>
<td>http://www.jsmith.com</td></tr>
<tr><td>Bach</td><td>Frank</td><td>fbach@yahoo.com</td><td>.00</td>
<td>http://www.frank.com</td></tr>
<tr><td>Doe</td><td>Jason</td><td>jdoe@hotmail.com</td><td>0.00</td>
<td>http://www.jdoe.com</td></tr>
<tr><td>Conway</td><td>Tim</td><td>tconway@earthlink.net</td><td>.00</td>
<td>http://www.timconway.com</td></tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() { $("#myTable").tablesorter(); $('table#myTable').floatThead(); }
);
</script>
</body>
</html>
我有下面的 MCVE 示例 table 来自 tablesorter@github
单击 table header 对 table 进行排序。当我添加此示例中注释的这一行 $('table#myTable').floatThead();
时,它将停止工作。
知道问题是什么以及如何解决吗?
<html lang="en">
<head>
<title>JQuery table sorter with JQuery floatThead MCVE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://rawgit.com/christianbach/tablesorter/master/jquery.tablesorter.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.1.2/jquery.floatThead.min.js"></script>
</head>
<body>
<table id="myTable" class="tablesorter" border=1>
<thead>
<tr><th>Last Name</th><th>First Name</th><th>Email</th><th>Due</th><th>Web Site</th></tr>
</thead>
<tbody>
<tr><td>Smith</td><td>John</td><td>jsmith@gmail.com</td><td>.00</td>
<td>http://www.jsmith.com</td></tr>
<tr><td>Bach</td><td>Frank</td><td>fbach@yahoo.com</td><td>.00</td>
<td>http://www.frank.com</td></tr>
<tr><td>Doe</td><td>Jason</td><td>jdoe@hotmail.com</td><td>0.00</td>
<td>http://www.jdoe.com</td></tr>
<tr><td>Conway</td><td>Tim</td><td>tconway@earthlink.net</td><td>.00</td>
<td>http://www.timconway.com</td></tr>
</tbody>
</table>
<script type="text/javascript">
//$('table#myTable').floatThead();
$(document).ready(function() { $("#myTable").tablesorter(); }
);
</script>
</body>
</html>
我偶然发现了一个非常简单的解决方案:顺序很重要!只需添加 $('table#myTable').floatThead();
AFTER 函数 tablesorter()
已被调用。
<html lang="en">
<head>
<title>JQuery table sorter with JQuery floatThead MCVE</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://rawgit.com/christianbach/tablesorter/master/jquery.tablesorter.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/floatthead/2.1.2/jquery.floatThead.min.js"></script>
</head>
<body>
<table id="myTable" class="tablesorter" border=1>
<thead>
<tr><th>Last Name</th><th>First Name</th><th>Email</th><th>Due</th><th>Web Site</th></tr>
</thead>
<tbody>
<tr><td>Smith</td><td>John</td><td>jsmith@gmail.com</td><td>.00</td>
<td>http://www.jsmith.com</td></tr>
<tr><td>Bach</td><td>Frank</td><td>fbach@yahoo.com</td><td>.00</td>
<td>http://www.frank.com</td></tr>
<tr><td>Doe</td><td>Jason</td><td>jdoe@hotmail.com</td><td>0.00</td>
<td>http://www.jdoe.com</td></tr>
<tr><td>Conway</td><td>Tim</td><td>tconway@earthlink.net</td><td>.00</td>
<td>http://www.timconway.com</td></tr>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() { $("#myTable").tablesorter(); $('table#myTable').floatThead(); }
);
</script>
</body>
</html>