gpt4 book ai didi

javascript - 在数据表中垂直滚动动画

转载 作者:太空宇宙 更新时间:2023-11-04 01:58:13 24 4
gpt4 key购买 nike

我想使用数据表显示所有数据。但我希望这些数据每 3 秒自动(动画)滚动每一行

这是我的代码,这是我的 jsfiddle

我想在大屏幕上显示数据。

<html>
<head>
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.1/css/jquery.dataTables.css">
<script type="text/javascript" src="//cdn.datatables.net/1.10.1/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/responsive/1.0.0/css/dataTables.responsive.css">
<script type="text/javascript" src="//cdn.datatables.net/responsive/1.0.0/js/dataTables.responsive.js"></script>
<style type="text/css">
table th:nth-child(3), td:nth-child(3) {
display: none;
}
</style>
<title>jQuery Datatables responsive example</title>
<script type='text/javascript'>
$(window).load(function(){
$(document).ready(function() {
$('#example').DataTable({
"scrollX": true,
"animate": true,
"bLengthChange": false,
"bFilter": false,
"bInfo" : false,
"paging": false
});
});
});
</script>
</head>
<body>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>

<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
</tbody>
</table>
</body>

</html>

帮帮我,谢谢

最佳答案

你可以像这样使用delay():

$(document).ready(function() {
$('#example').DataTable({
"scrollX": true,
"animate": true,
"bLengthChange": false,
"bFilter": false,
"bInfo" : false,
"paging": false
});

$('#example > tbody > tr').each(function() {
$('html, body').animate({
scrollTop: $(this).offset().top
}, 200).delay(2800);
});

} );

fiddle

关于javascript - 在数据表中垂直滚动动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42220756/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com